UINavigationController

//

//ViewController.swift

//UINavigationController

//

//Created by SZT on 2016/11/2.

//Copyright © 2016年SZT. All rights reserved.

//

importUIKit

classViewController:UIViewController{

overridefuncviewDidLoad() {

super.viewDidLoad()

//每一个被导航视图控制器所管理的视图控制器都有一个navigationItem(这里面包含了左按钮,右按钮,中间标题,中间视图)

//设置导航栏的标题

navigationItem.title="Setting"

letleftBarBtn =UIBarButtonItem(barButtonSystemItem: .Camera, target:self, action:"leftBtnAction")

//设置右边按钮

letrightBarBtn =UIBarButtonItem(title:"next", style:UIBarButtonItemStyle.Plain, target:self, action:"rightBtnAction")

//设置导航栏左按钮leftBarButtonItem:(UIBarButtonItem)

//navigationItem.leftBarButtonItem = leftBarBtn

//navigationItem.rightBarButtonItem = rightBarBtn

//设置左右item数组

navigationItem.leftBarButtonItems= [leftBarBtn,rightBarBtn]

navigationItem.rightBarButtonItems= [leftBarBtn,rightBarBtn]

//设置中间视图

letsegment =UISegmentedControl(items: ["已接来电","未接来dian"])

segment.frame=CGRectMake(0,0,100,30)

segment.selectedSegmentIndex=1

//设置中间视图

navigationItem.titleView= segment

}

funcrightBtnAction(){

print("click right Btn")

}

funcleftBtnAction(){

print("click left Btn")

}

overridefuncdidReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

}

你可能感兴趣的:(UINavigationController)