Dan*_*182 9 uibutton uibarbuttonitem swift
如何使用信息灯UIBarButtonItem?
我不想使用自定义图像,因为结果不是很好.
我想使用Apple"信息"按钮.
我正在使用Swift.
谢谢.
mok*_*gio 24
没有直接的方法来使用UIBarButtonItemAPI创建这样的条形按钮.
您可以使用虽然配置了一个自定义视图.InfoLight UIButton,如建议在这里:
// Create the info button
let infoButton = UIButton(type: .infoLight)
// You will need to configure the target action for the button itself, not the bar button itemr
infoButton.addTarget(self, action: #selector(getInfoAction), for: .touchUpInside)
// Create a bar button item using the info button as its custom view
let infoBarButtonItem = UIBarButtonItem(customView: infoButton)
// Use it as required
navigationItem.rightBarButtonItem = infoBarButtonItem
Run Code Online (Sandbox Code Playgroud)
如果您需要更多帮助,请随时发表评论.
改编 mokagio 对 Obj-C 的出色回答:
UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(getInfoAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* infoBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
self.navigationItem.rightBarButtonItem = infoBarButtonItem;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3950 次 |
| 最近记录: |