我正在尝试更改我的一个视图控制器的字体大小,因为它适用于更多文本,因此需要比我的其他视图更小的字体大小.我在didFinishLaunchingWithOptions期间在appdelegate中设置导航栏属性,然后在viewDidLoad期间为我的视图控制器设置字体.但是,当我返回屏幕或向前时,我保留对导航栏所做的更改,即较小的字体.有没有解决的办法?例如,在退出视图时将字体设置回正常状态?
Cliffsnotes:尝试在一个视图控制器中设置字体,但是一旦我设置它,它就适用于所有视图控制器.
代码如下:
在AppDelegate中:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor clearColor],UITextAttributeTextColor,[UIColor whiteColor],UITextAttributeTextShadowColor,[NSValue valueWithUIOffset:UIOffsetMake(0,-1)],UITextAttributeTextShadowOffset,[UIFont fontWithName:@"QuicksandBold-Regular" size:24.0],UITextAttributeFont,nil]];
在视图控制器viewDidLoad中:
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor clearColor],[UIFont fontWithName:@"QuicksandBold-Regular" size:18.0],nil]];