如何在导航栏中添加/使用默认图标 [英] How to add / use default icons to navigation bar
本文介绍了如何在导航栏中添加/使用默认图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用一些默认
。$
基本上我不知道如何调用该项目的图像(直接来自本机库 - 我知道如何下载并放置为自定义图像:)):
in navigation bar.
Basically I don't know how to call image of that item (directly from native library - I know how to download it and place as custom image:)):
var myButton:UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
myButton.addTarget(self, action: "reload", forControlEvents: UIControlEvents.TouchUpInside)
myButton.setImage(???, forState: <#UIControlState#>)
推荐答案
您可以使用 UIBarButtonSystemItem
这样:
let button = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Refresh, target: self, action: "someAction")
navigationItem.leftBarButtonItem = button
leftBarButtonItem $ c的结果$ c>:
如果您要设置它在右侧你可以使用这个代码:
If you want to set it at right side you can use this code:
navigationItem.rightBarButtonItem = button
的结果rightBarButtonItem
:
这篇关于如何在导航栏中添加/使用默认图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文