自定义navigationBar后退图像阴影已删除

时间:2018-02-26 16:01:49

标签: ios swift

我正在设置自定义后退按钮图片,但我很难找到导航栏从图像中删除阴影的原因

override func viewDidLoad() {
    super.viewDidLoad()
    navigationController?.navigationBar.barStyle = .black

    let transparentPixel = UIImage()
    navigationController?.navigationBar.setBackgroundImage(transparentPixel, for: UIBarMetrics.default)
    navigationController?.navigationBar.backgroundColor = .clear
    navigationController?.navigationBar.isTranslucent = true
    navigationController?.navigationBar.backIndicatorImage = #imageLiteral(resourceName: "arrowBackShadow")
    navigationController?.navigationBar.backIndicatorTransitionMaskImage = #imageLiteral(resourceName: "arrowBackShadow")
    navigationController?.navigationBar.barTintColor = .white
    navigationController?.navigationBar.tintColor = .white
}

但是如下所示,我的图像阴影被删除(第二个后退箭头显示在UIImageView中以供比较) enter image description here

这是我的箭头:enter image description here

1 个答案:

答案 0 :(得分:2)

By default nav bar suggests that you providing it with "Template" image. If you want to use image as "it is", you had to set up it explicitly. For example in "Assets":

enter image description here

enter image description here