📜  swift iOS15 导航栏样式不起作用 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:01:03.380000             🧑  作者: Mango

代码示例1
// Make sure you also add the scrollEdgeAppearance in >iOS15!

let backgroundColor = .yellow
let tintColor = .white

if #available(iOS 13.0, *) {
  let navBarAppearance = UINavigationBarAppearance()
  navBarAppearance.configureWithDefaultBackground()
  navBarAppearance.backgroundColor = .clear
  navBarAppearance.backgroundImage = UIImage(color: backgroundColor)

  navBarAppearance.shadowColor = nil
  self.navigationBar.standardAppearance = navBarAppearance
  self.navigationBar.compactAppearance = navBarAppearance

  // Important to add:
  self.navigationBar.scrollEdgeAppearance = navBarAppearance
}