我正在尝试更改快速导航栏中后退按钮的颜色。
这是我当前的代码,该代码为我提供了三个后退箭头作为后退按钮项,但是如何更改颜色,以便在一小段文本中出现三种不同的颜色? (绿色,黄色,红色)。
func setCustomBackImage() {
navigationItem.backBarButtonItem = UIBarButtonItem(title: "<<<", style: .plain, target: nil, action: nil)
}
答案 0 :(得分:1)
答案 1 :(得分:1)
还有一种更简单的方法,因为您说“ 我还挺新的”,那么您就可以了!
//add this in AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let backArrowImage = UIImage(named: "icon50")
let renderedImage = backArrowImage?.withRenderingMode(.alwaysOriginal)
UINavigationBar.appearance().backIndicatorImage = renderedImage
UINavigationBar.appearance().backIndicatorTransitionMaskImage = renderedImage
return true
// This will change all back-arrows to whatever image you want
}
此处“ icon50”应为“ <<<”图像。 Td:lr,使用图片。
希望它会有所帮助:)