现在的位置: 首页 > 综合 > 正文

添加 UINavigationBar 和 UINavigationItem

2018年04月15日 ⁄ 综合 ⁄ 共 807字 ⁄ 字号 评论关闭

UINavigationItem *navItem = [[UINavigationItem
alloc]
init];

UINavigationBar *navigationbar = [[UINavigationBar
alloc] init]; 

navigationbar.items = [NSArray
arrayWithObject:navItem];

    

//添加 leftbutton and rightbutton

UIBarButtonItem* backbutton = [[UIBarButtonItem
alloc] initWithTitle:@"返回"
style:UIBarButtonItemStyleDone
target:self
action:@selector(back:)];  

UIBarButtonItem*
right
button = [[UIBarButtonItem
alloc] initWithTitle:@"评论"
style:UIBarButtonItemStyleDone
target:self
action:@selector(ShowTalkview:)];

  

[navItem
setLeftBarButtonItem
:backbutton];

[navItem
setRightBarButtonItem:rightbutton];

//添加标题
   

navItem.title =
@"回复";

//修改UINavigationBar 颜色

navigationbar.tintColor = [UIColor
colorWithRed:117/255.0f
green:173/255.0f
blue:162/255.0f
alpha:1];

self.view.backgroundColor
= [
UIColor
colorWithRed:219/255.0f
green:235/255.0f
blue:223/255.0f
alpha:1];

抱歉!评论已关闭.