Swift: 你好, UIKit!

Swift: 你好, UIKit!,第1张

概述创建主入口 main.swift: import UIKitUIApplicationMain( Process.argc, Process.unsafeArgv, NSStringFromClass(MainApp), NSStringFromClass(MainAppDelegate)) 创建 app.swift, 对应 MainApp 和 MainAppDelegate 的实现:

创建主入口 main.swift:

import UIKitUIApplicationMain(	Process.argc,Process.unsafeArgv,NsstringFromClass(MainApp),NsstringFromClass(MainAppDelegate))

创建 app.swift,对应 MainAppMainAppDelegate 的实现:

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!所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1074831.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存