如何制作这样的UIBarButtonItem

我怎么能像这样制作一个UIBarButtonItem: 在此处输入图像描述

我在SystemItem值中找不到它。

谢谢

这可能是使用类似的东西:

[[UIBarButtonItem alloc] initWithImage:@"info.png" style:UIBarButtonItemStyleBordered target:nil action:nil] 

我尝试过:

 UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:[UIButton buttonWithType:UIButtonTypeInfoLight]]; item.style = UIBarButtonItemStyleBordered; 

但似乎有一个自定义视图,边框样式不会被应用。

你称之为信息按钮的图像按钮。这是一个系统按钮,

使用下面的内容将其作为rightBarButtonItem

 UIButton* myInfoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; [myInfoButton addTarget:self action:@selector(InfoButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myInfoButton]; 

这是UIButtonType的文档链接

Swift版本的@Jhaliya快速复制粘贴的答案:

 let infoButton = UIButton(type: .InfoLight) infoButton.addTarget(self, action: "InfoButtonClicked:", forControlEvents: .TouchUpInside) let infoBarButtonItem = UIBarButtonItem(customView: infoButton) navigationItem.rightBarButtonItem = infoBarButtonItem