有没有办法立即对整个应用程序应用自定义外观?

时间:2012-08-17 07:34:47

标签: iphone objective-c ios appearance

例如,我有一个方法:

- (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]];
}

如何使这种方法适用于整个应用程序?

2 个答案:

答案 0 :(得分:3)

如果您将此代码放入应用所有应用的finished lunching方法中的应用代理中。

请注意,这仅适用于iOS 5

答案 1 :(得分:1)

如果你在UIViewController中使用它,只需创建自己的子类MyUIViewController,你就可以在你创建的每个新屏幕中使用它。只需使用MyUIViewController作为屏幕的超类,而不是普通的UIViewControler。

一般来说,这是一个好主意,因为只需更改MyUIViewController中的代码,就可以轻松地将其他行为添加到所有屏幕。

相关问题