Navigation Bar Title Font Size

后端 未结 5 1517
栀梦
栀梦 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:33

    You got it already,but you can also use following attributes methods.

    For Color,

    NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor RedColor],UITextAttributeTextColor, nil];
    
    self.navigationController.navigationBar.titleTextAttributes = attributes;
    

    For Size,

    NSDictionary *size = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:17.0],UITextAttributeFont, nil];
    
    self.navigationController.navigationBar.titleTextAttributes = size;
    

    Thanks.

    For iOS 7 and above

    For Size:

    NSDictionary *size = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:17.0],NSFontAttributeName, nil];
    
    self.navigationController.navigationBar.titleTextAttributes = size;
    

提交回复
热议问题