Navigation Bar Title Font Size

后端 未结 5 1499
栀梦
栀梦 2020-12-10 03:38

I need to change the size of the Navigation Bar title text for one view controller in my iPhone app. I\'m using iOS5, and tried the following code:

if ([self         


        
5条回答
  •  醉梦人生
    2020-12-10 04:28

    Swift 2.0:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            UINavigationBar.appearance().titleTextAttributes = [
                NSFontAttributeName: UIFont(name: "DINNextLTW04-Regular", size: 20)!
            ]
    
            return true
        }
    

    Or

     override func viewDidLoad() {
      super.viewDidLoad()
    
      self.navigationController?.navigationBarHidden =  false
      self.title = "SAMPLE"
    
    //Set Color
      let attributes: AnyObject = [ NSForegroundColorAttributeName: UIColor.redColor()]
      self.navigationController!.navigationBar.titleTextAttributes = attributes as? [String : AnyObject]
    
    
    //Set Font Size
      self.navigationController!.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Arial", size: 37.0)!];
    
     }
    

提交回复
热议问题