当我使用原生颜色时,我使用导航栏色调颜色命名导航栏后退按钮,当我使用图像中的自定义颜色时,它会失败。
工作代码:
self.navigationController?.navigationBar.tintColor = UIColor.orange
不工作代码:
let color = UIColor.init(patternImage: someImage)
self.navigationController?.navigationBar.tintColor = color
有人能表现出一些亮点吗?
答案 0 :(得分:2)
您不能将图案颜色用作色调颜色。
请参考以下链接: https://developer.apple.com/documentation/uikit/uiview/1622467-tintcolor
重要
如果您尝试将图案颜色用作色彩,系统 引发异常。
答案 1 :(得分:0)
如果您有图像,请将导航栏中的图像设置为背景图像。喜欢:
self.navigationController?.navigationBar.setBackgroundImage(#imageLiteral(resourceName: "NavigationBackground"), for: .default)
希望这有用。