在
UINavigationBar
中,我在storyboard
中设置了右栏项目图像。点击时是highlighted
。我想通过将“突出显示调整图像”设置为 false 来禁用突出显示。如何访问此属性?
您可以使用
withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
作为图像来解决此问题:
let img = UIImage(named: "picture")!.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
let rightBarButtonItem = UIBarButtonItem(image: img, style: UIBarButtonItem.Style.plain, target: self, action: nil)
self.navigationItem.rightBarButtonItem = rightBarButtonItem