在将导航条设置为透明后,我在恢复iOS 11大标题的bartint颜色方面出现了问题。
复制步骤:
Tried:
*将导航背景颜色和状态颜色设置为条形色调,是的,它改变了,但是没有半透明的视觉效果,就像我们设置的条色一样。
有没有人像我一样面对同样的问题,并能用任何解决方案或解决办法来解决这个问题?
原始

在浏览了一个具有透明导航的页面之后返回了

FYI,我还应用自定义导航控制器将透明颜色设置为默认颜色,
class CustomNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
super.pushViewController(viewController, animated: animated)
self.setDefaultNavigationBar()
}
override func popViewController(animated: Bool) -> UIViewController? {
self.setDefaultNavigationBar()
return super.popViewController(animated: animated)
}
override func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? {
self.setDefaultNavigationBar()
return super.popToViewController(viewController, animated: animated)
}
override func popToRootViewController(animated: Bool) -> [UIViewController]? {
self.setDefaultNavigationBar()
return super.popToRootViewController(animated: animated)
}
func setDefaultNavigationBar() {
let navigationBarColor = UIColor(hexString: "#00b5baff")!
self.navigationBar.setBackgroundImage(nil, for: .default)
self.navigationBar.shadowImage = nil
//self.navigationController?.navigationBar.backgroundColor = UIColor.clear
//self.navigationController?.navigationBar.tintColor = UIColor.clear
self.navigationBar.barTintColor = navigationBarColor
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/}
发布于 2018-01-04 23:18:33
尝试将transparent.png图像作为背景图像来实现透明性。那应该管用。如果这不起作用,试着使用下面的代码来更新大标题颜色。
self.navigationController?.navigationBar.largeTitleTextAttributes =
[NSAttributedStringKey.foregroundColor: UIColor.blue,
NSAttributedStringKey.font: UIFont(name: fontName, size: 30) ??
UIFont.systemFont(ofSize: 30)]希望这能有所帮助!
发布于 2019-10-31 11:39:47
不确定这是否对任何人有帮助,但当我在选择“更喜欢的大标题”后导航背景颜色变成白色时,这才是对我有用的:
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = FlatBlue()
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.white]
navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = appearancehttps://stackoverflow.com/questions/48077336
复制相似问题