例如,我有一个方法:
- (void)customizeAppearance
{
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0],
UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Arial-Bold" size:0.0],
UITextAttributeFont,
nil]];
}
如何使这种方法适用于整个应用程序?
答案 0 :(得分:3)
如果您将此代码放入应用所有应用的finished lunching
方法中的应用代理中。
请注意,这仅适用于iOS 5
答案 1 :(得分:1)
如果你在UIViewController中使用它,只需创建自己的子类MyUIViewController,你就可以在你创建的每个新屏幕中使用它。只需使用MyUIViewController作为屏幕的超类,而不是普通的UIViewControler。
一般来说,这是一个好主意,因为只需更改MyUIViewController中的代码,就可以轻松地将其他行为添加到所有屏幕。