UIBarButtonItem 问题
Issue with UIBarButtonItem
我的 UIBarButton 有问题,按钮的颜色与我的原始图像不同。
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "settings.png"), style: .Plain, target: self, action: "didTapSettingButton")
按钮的颜色是蓝色,但我的图像是黄色的!
像这样:
如果你能帮助我就太好了:)
这样试试。
在您的 class var settingRightBarButton : UIBarButtonItem?
中创建一个栏按钮 属性
然后
let shareBarButtonImage = UIImage(named: "settings")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
self.settingRightBarButton = UIBarButtonItem(image: shareBarButtonImage, style: UIBarButtonItemStyle.Plain, target: self, action: Selector("didTapSettingButton"))
self.navigationItem.rightBarButtonItem = self.settingRightBarButton
在 Images.xcassets
中添加您的图片
试试这个代码:
var image : UIImage? = UIImage(named:"settings.png").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
设置图片UIImageRenderingMode
属性:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "settings.png").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), style: .Plain, target: self, action: "didTapSettingButton")
我的 UIBarButton 有问题,按钮的颜色与我的原始图像不同。
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "settings.png"), style: .Plain, target: self, action: "didTapSettingButton")
按钮的颜色是蓝色,但我的图像是黄色的!
像这样:
如果你能帮助我就太好了:)
这样试试。
在您的 class var settingRightBarButton : UIBarButtonItem?
然后
let shareBarButtonImage = UIImage(named: "settings")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
self.settingRightBarButton = UIBarButtonItem(image: shareBarButtonImage, style: UIBarButtonItemStyle.Plain, target: self, action: Selector("didTapSettingButton"))
self.navigationItem.rightBarButtonItem = self.settingRightBarButton
在 Images.xcassets
试试这个代码:
var image : UIImage? = UIImage(named:"settings.png").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
设置图片UIImageRenderingMode
属性:
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "settings.png").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), style: .Plain, target: self, action: "didTapSettingButton")