博客> 自定义NavigationBar
自定义NavigationBar
2019-10-12 13:11 评论:0 阅读:789 Lucas_Lin
swift navigationBar

import UIKit

class LLViewController: UIViewController {

   override func viewDidLoad() {`
    super.viewDidLoad()
    //设置视图颜色
    view.backgroundColor = UIColor.yellow
    //设置navigationBar的背景图片.以单位像素的图片填充背景.
    navigationController?.navigationBar.setBackgroundImage(UIImage(named: "navigationbar"), for: UIBarMetrics.default)
    //设置navigationItem的title
    navigationItem.title = "Lucas"
    //设置title的字体以及颜色
    navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName : UIFont.systemFont(ofSize: 20), NSForegroundColorAttributeName : UIColor.red]
   }

}

收藏
1
sina weixin mail 回到顶部