developing iOS Apps with Lua (Wax)
1. Create a new iOS project Waxdemo.
2. Delete the native. h and. m
3. Download the wax framework wget Https://github.com/downloads/probablycorey/wax/wax.framework.zip
4. Pull the wax.framework into the project
5. Add Init.lua and Viewcontroller.lua two files
6.coding, adding LUA initialization code- (BOOL) Application: (uiapplication*) Application didfinishlaunchingwithoptions: (nsdictionary*) Launchoptions {
Self.window= [[UIWindowAlloc]initWithFrame:[[UIScreenMainscreen]bounds]];
Self.window.BackgroundColor= [UicolorWhitecolor];
[ Self.windowmakekeyandvisible];
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. Run, then it works!
Developing iOS apps with Lua (Wax)