ios配置啟動后的第一個頁面(引導頁或首頁)


在AppDelegate.swift中配置ViewController.swift為啟動后的第一個頁面

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

  // 啟動后的第一個頁面

        self.window = UIWindow(frame: UIScreen.mainScreen().bounds);

        

        //        //跳轉到無導航欄的ViewController()

        //        let vc = ViewController();

        //        window?.rootViewController = vc;//本行vc處填寫你要選擇的頁面

        //        window?.makeKeyAndVisible();

        

        //跳轉到有導航欄的ViewController()

        let mvc = UINavigationController(rootViewController: ViewController())

        window?.rootViewController =  mvc

        window?.makeKeyAndVisible()

 

        return true;
    }

在ViewController.swift中簡單寫一下背景色

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.view.backgroundColor = .yellowColor();//背景色的設置
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

 

然后運行就出現了黃色的頁面 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM