如何制作类似这样的UIBarButtonItem:
在SystemItem值中找不到它。
谢谢
![enter image description here](https://istack.dev59.com/V1dxi.webp)
谢谢
你所称之为信息按钮的图像按钮,是一个系统按钮。
使用以下代码将其作为你的rightBarButtonItem获取:
UIButton* myInfoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[myInfoButton addTarget:self action:@selector(InfoButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myInfoButton];
这里是链接到UIButtonType的文档:UIButtonType
[[UIBarButtonItem alloc] initWithImage:@"info.png" style:UIBarButtonItemStyleBordered target:nil action:nil]
我尝试使用以下方法:
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:[UIButton buttonWithType:UIButtonTypeInfoLight]];
item.style = UIBarButtonItemStyleBordered;
以下是Swift版本的@Jhaliya的答案,可快速复制粘贴:
let infoButton = UIButton(type: .InfoLight)
infoButton.addTarget(self, action: "InfoButtonClicked:", forControlEvents: .TouchUpInside)
let infoBarButtonItem = UIBarButtonItem(customView: infoButton)
navigationItem.rightBarButtonItem = infoBarButtonItem