学Swift挣美金

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

2019-05-02  本文已影响42人  iCloudEnd

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
    }

}

上一篇 下一篇

猜你喜欢

热点阅读