swift代码生成navigationController

来源:互联网 发布:中国网络什么时候墙的 编辑:程序博客网 时间:2024/04/30 23:52

关键代码

 func application(application:UIApplication!, didFinishLaunchingWithOptions launchOptions:NSDictionary!) -> Bool {

       

        

        let rvc:ViewController=ViewController()

       let nav=UINavigationController(rootViewController: rvc)

        self.window!.rootViewController=nav

       return true

    }



===============================

class ViewController:UIViewController {

    

 var mylable=UILabel()

    

  //  @IBOutlet strong var uiview: UIView

                            

   override func viewDidLoad() {

       super.viewDidLoad()

       self.title="nimei"

        

       self.view.backgroundColor=UIColor.whiteColor()

        

        

       

        

      var but=UIButton(frame:CGRect(x:11, y: 12, width:23, height: 34))

        but.backgroundColor=UIColor.whiteColor()

       self.view.addSubview(but)

        

       var la=UILabel(frame:CGRect(x:100, y: 100, width:220, height: 50))

        la.text="nishiahsbima"

       self.view.addSubview(la)

        

       let nextItm=UIBarButtonItem(title:"xiayie", style:.Plain, target:self, action: "niemi");

        self.navigationItem.rightBarButtonItem=nextItm

        

        

        

    }

   func niemi(){

        let sev:secondview=secondview()

       self.navigationController.pushViewController(sev,animated:true)}


===========================================

import Foundation

import UIKit

class secondview:UIViewController{


   override func viewDidLoad() {

    

    super.viewDidLoad()

        self.view.backgroundColor=UIColor.whiteColor()

        

    

    

    }


}


0 0
原创粉丝点击