Swift如何改变backIndicatorImage的tintColor

时间:2017-08-08 09:31:31

标签: ios swift

我在AppDelegate中获得了此代码 û

INavigationBar.appearance().backIndicatorImage = #imageLiteral(resourceName: "backarrow")

即使图像的颜色为白色,也会显示为蓝色。如何更改此图像的色调?

2 个答案:

答案 0 :(得分:1)

  1. 转到Assets.xcassets
  2. 选择您的图片backarrow
  3. 显示Attributes Inspector
  4. Render As值格式Default更改为Original Image
  5. enter image description here

答案 1 :(得分:0)

Swift 5.x和Xcode 12解决方案

let image = UIImage(named: "abc")!.withRenderingMode(.alwaysOriginal)
navigationBar.backIndicatorImage = image
navigationBar.backIndicatorTransitionMaskImage = image