iOS UINavigationController

1.获取当前控制器

    nav.topViewController

2.设置导航栏背景透明

    self.navigationBar.setBackgroundImage(UIImage(),for: .default)
    self.navigationBar.shadowImage = UIImage()

3.设置导航条 标题颜色、大小

     self.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: font,NSAttributedStringKey.foregroundColor: titleColor] as [NSAttributedStringKey : Any]

4.设置导航栏背景图片

    let bgImage = UIImage(named: imageName!)?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch)
    self.navigationBar.setBackgroundImage(bgImage, for: .default)

你可能感兴趣的:(iOS UINavigationController)