//在 AppDelegate.h中写方法
func setNavigationBarStyle() ->Void{
var bgImage = UIImage(named: "导航矩形3x.png")?.resizableImage(withCapInsets: UIEdgeInsets(), resizingMode: .stretch)
UINavigationBar.appearance().setBackgroundImage(bgImage, for: .default)
//设置navigationbar 压缩图片后出现横线,通过此方法消除横线阴影
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white] //设置title颜色
扫描二维码关注公众号,回复:
2460371 查看本文章
}