in AppDelegate.swift I have following code:
let nav1 = UINavigationController()
let mainView = ViewController(nibName: nil, bundle: nil) //ViewController = Name of your controller
nav1.viewControllers = [mainView]
nav1.navigationBar.topItem?.title = "JT"
nav1.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "AvenirNext-UltraLight", size: 24)!, NSForegroundColorAttributeName: UIColor.whiteColor()]
But last line doesn't change font of title of nav bar What i should do?
您可以通过情节提要更改导航栏标题属性,或尝试以下操作:
nav1.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "AvenirNext-UltraLight", size: 24)!, NSForegroundColorAttributeName: UIColor.whiteColor()]
You can create you own titleView like this:
let label=UILabel(frame: nav1.navigationBar.frame)
label.textAlignment=NSTextAlignment.Center
label.font=UIFont(name: "FONT HERE", size: 27)
label.text="TITLE HERE"
label.textColor=UIColor.blackColor()
for item in nav1.navigationBar.items!{
item.titleView=label
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.