当向导航栏添加bar button item时,总是会自动添加到toolbar,可能是navigation bar没有显示的原因,于是我向界面中添加一个 navigation bar,这个时候这个“字体可以显示在上面”,但是新的问题又来了,界面中有了两个导航栏,这不是我想要的,问:怎么直接在这个界面的导航栏上添加“字体”按钮呢?
加哪?你想加记事本那页面的导航栏上?
我添加导航栏都是选中那个页面,editor-》embed in-》navigation controller。添加按钮的话直接拖bar button item 上去就行了
- (void)layoutButton{
UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
button.frame = CGRectMake(0, 0, 20, 20);
[button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
// [button setImage:[UIImage imageNamed:@"iconfont-help"] forState:(UIControlStateNormal)];
[button addTarget:self action:@selector(pictureShow) forControlEvents:(UIControlEventTouchUpInside)];
UIBarButtonItem *leftBt = [[UIBarButtonItem alloc]initWithCustomView:button];
self.navigationItem.leftBarButtonItem = leftBt;
}
填到哪自己去选择,我选的是左边的 你可以选择rightBarButtonItem
先把topbar显示出来,storyboard中选择一种类型,然后拖个navigation item 到topbar上,然后再拖bar button item 到navigation item 上 ,还不行的话具体问