美文网首页
iOS15 UINavigationBar、UITabBar

iOS15 UINavigationBar、UITabBar

作者: 東玖零 | 来源:发表于2021-09-22 12:37 被阅读0次

不多说了,上代码:
navigationBar 设置如下:

if #available(iOS 15, *) {
     let appearance = UINavigationBarAppearance()
     appearance.configureWithOpaqueBackground()
     appearance.backgroundImage = UIImage(named: "navigation-back-img")
     appearance.shadowImage = UIImage()
     appearance.shadowColor = UIColor.clear
     appearance.titleTextAttributes = [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18),NSAttributedString.Key.foregroundColor:k_FFFFFF]
     navigationBar.standardAppearance = appearance
     navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance
}

UITabBar设置如下:

if #available(iOS 15, *) {
     let appearance = UITabBarAppearance()
     appearance.configureWithOpaqueBackground()
     appearance.backgroundColor = k_FAFAFA
     UITabBar.appearance().standardAppearance = appearance
     UITabBar.appearance().scrollEdgeAppearance = UITabBar.appearance().standardAppearance
}

原文来自苹果开发者社区:https://developer.apple.com/forums/thread/682420

相关文章

网友评论

      本文标题:iOS15 UINavigationBar、UITabBar

      本文链接:https://www.haomeiwen.com/subject/mwangltx.html