我不能在故事板中同时将标题和图像设置到导航栏上的右栏项目吗?

时间:2017-04-24 06:36:22

标签: ios storyboard uibarbuttonitem navigationbar

我想将右键项设置为:

enter image description here

它有标题和下图。

但在故事板中,我做不到:

enter image description here

我只能设置一个标题和图像,如果我设置图像,我无法设置标题,如果我设置标题,我就无法设置图像。

我尝试使用UIButton和Button Bar Item来做到这一点,得到相同的结果。

有些朋友知道怎么办?

2 个答案:

答案 0 :(得分:1)

您可以在storyBoard中添加拖拽UIButton到rightBarItem。并根据您的需要自定义该按钮..

添加UIButton后检查视图层次结构。

enter image description here

答案 1 :(得分:0)

您可以尝试将自定义视图添加到条形按钮项

var RightView = UIView(frame: CGRectMake(0, 0, 100, 44))
// you can add in RightView, your title in uilable and your image in imageview  
var RightBarButton = UIBarButtonItem(customView: RightView)
self.navigationItem.rightBarButtonItem = RightBarButton