码迷,mamicode.com
首页 > 移动开发 > 详细

用lua开发iOS应用(Wax)

时间:2015-05-06 17:56:51      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:lua   ios   wax   

用lua开发iOS应用(Wax)

1.新建一个iOS工程WaxDemo.
技术分享
技术分享

2.把原生的.h和.m删除
技术分享

3.把wax的framework下载下来
wget https://github.com/downloads/probablycorey/wax/wax.framework.zip

4.把wax.framework拉进去工程
技术分享

5.添加init.lua和ViewController.lua两个文件
技术分享

6.coding,添加lua初始化代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   
self.window.backgroundColor = [UIColor whiteColor];
    [
self.window makeKeyAndVisible];
   
wax_start("init.lua", nil);
   
return YES;
}

6.init.lua
require "ViewController"
viewController = ViewController:init()
window = UIApplication:sharedApplication():keyWindow()
window:setRootViewController(viewController)

7.viewController.lua
waxClass{"ViewController", UIViewController}
function viewDidLoad(self)
self.super:viewDidLoad(self)

local label = UILabel:initWithFrame(CGRect(0, 120, 320, 40))
label:setColor(UIColor:blackColor())
label:setText("Hello World!")
label:setTextAlignment(UITextAlignmentCenter)
local font = UIFont:fontWithName_size("Helvetica-Bold",50)
label:setFont(font)
self:view():addSubview(label)
end

8.运行,then it works!
技术分享

用lua开发iOS应用(Wax)

标签:lua   ios   wax   

原文地址:http://blog.csdn.net/rainlesvio/article/details/45536657

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!