IOS swift3.1 创建Swift空工程(无storyBoard)纯代码方式编写APP

1.新建工程

IOS swift3.1 创建Swift空工程(无storyBoard)纯代码方式编写APP


2找到工程的TAGETS/General/Deployment Info 如下图,删除Main。

.IOS swift3.1 创建Swift空工程(无storyBoard)纯代码方式编写APP


3.删除Main.storyboard,选择“Move to Trash"( 这里不需要删除info.plist中的 Main storyboard file base name项,

已经不在了)

IOS swift3.1 创建Swift空工程(无storyBoard)纯代码方式编写APP


4. 在AppDelegate.swift文件对应函数添加以下代码


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = ViewController()
        window?.backgroundColor = UIColor.white
        window?.makeKeyAndVisible()

        return true
    }