创建主入口 main.swift
:
import UIKitUIApplicationMain( Process.argc,Process.unsafeArgv,NsstringFromClass(MainApp),NsstringFromClass(MainAppDelegate))
创建 app.swift
,对应 MainApp
和 MainAppDelegate
的实现:
import UIKitclass MainApp: UIApplication { overrIDe func sendEvent(event: UIEvent) { super.sendEvent(event) }}class MainAppDelegate: UIResponder,UIApplicationDelegate { var window: UIWindow? func application(app: UIApplication,dIDFinishLaunchingWithOptions opt: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) self.window!.rootVIEwController = UIVIEwController() self.window!.backgroundcolor = UIcolor.whitecolor() self.window!.makeKeyAndVisible() self.window!.AddSubvIEw { let label = UILabel(frame: self.window!.frame) label.textAlignment = .Center label.text = "你好,UIKit!" return label } return true }}extension UIVIEw { func AddSubvIEw(subvIEw: ()->UIVIEw) { self.addSubvIEw(subvIEw()) }}
运行效果:
总结以上是内存溢出为你收集整理的Swift: 你好, UIKit!全部内容,希望文章能够帮你解决Swift: 你好, UIKit!所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)