gpt4 book ai didi

ios - 导航栏颜色设置不正确

转载 作者:行者123 更新时间:2023-11-29 05:45:15 25 4
gpt4 key购买 nike

我正在尝试设置导航栏颜色。我在此应用程序中不使用 Storyboard,因此必须用代码完成。目前我有这个:

 navigationController.navigationBar.isHidden = false
navigationController.navigationBar.backgroundColor = UIColor(named: "tint")

navigationController.navigationBar.shadowImage = UIImage()
navigationController.navigationBar.isTranslucent = true
navigationController.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController.navigationBar.tintColor = .white
navigationController.navigationBar.titleTextAttributes =[NSAttributedString.Key.foregroundColor: UIColor.white]

实际上我得到了: enter image description here

为什么导航栏上面的颜色不一样?

最佳答案

UINavigationBar.appearance().backgroundColor = UIColor.greenColor()
UIBarButtonItem.appearance().tintColor = UIColor.magentaColor()
UINavigationBar.appearance().titleTextAttributes = [UITextAttributeTextColor: UIColor.blueColor()]
UITabBar.appearance().backgroundColor = UIColor.yellowColor();

有关 Swift 中 UIAppearance API 的更多信息,您可以在此处阅读:https://developer.apple.com/documentation/uikit/uiappearance

UINavigationBar.appearance().barTintColor = .black
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
UINavigationBar.appearance().isTranslucent = false

关于ios - 导航栏颜色设置不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56219235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com