美文网首页学Swift挣美金
Swift通过代码创建项目和视图不使用storyboard

Swift通过代码创建项目和视图不使用storyboard

作者: iCloudEnd | 来源:发表于2019-05-02 10:27 被阅读42次

Swift通过代码创建项目和视图不使用storyboard

storyboard虽然非常强大,但是作为一个自由的开发者我们不应该被鼠标键盘束缚。最好的设计软件就是我们强大的内心。

新建一个项目

修改一下背景

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        view.backgroundColor = .yellow
    }


}

不使用storyboard 创建一个项目

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        window = UIWindow()
        window?.makeKeyAndVisible()
        window?.rootViewController = ViewController()
        return true
    }

}

相关文章

网友评论

    本文标题:Swift通过代码创建项目和视图不使用storyboard

    本文链接:https://www.haomeiwen.com/subject/huxnnqtx.html