titleTextAttributes UIAppearance font in iOS 7

前端 未结 7 1587
醉酒成梦
醉酒成梦 2020-12-08 09:47

I am using UIAppearance to apply fonts to UINavigationBar and UIBarButtonItem and I am having problems. I ran this code:

[[UIBarButtonItem appearanceWhenCont         


        
7条回答
  •  隐瞒了意图╮
    2020-12-08 10:28

    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont 
        fontWithName:@"YOURFONT" size:14], NSFontAttributeName, 
        [UIColor whiteColor], NSForegroundColorAttributeName, nil];
    
    [[UINavigationBar appearance] setTitleTextAttributes:attributes];
    

    The key is to use NSFontAttributeName and so forth. I assume they are moving over to using the NS variety for 64-bit compatibility. The above code worked on my iOS7 device.

提交回复
热议问题