2012-08-17 35 views
0

例如,我有一個方法:是否有辦法一次將自定義外觀應用於整個應用程序?

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

我怎樣才能讓使用此法工作了整個應用程序?

回答

3

如果您將此代碼放入您的應用程序委託中的finished lunching方法中,該方法將影響所有應用程序。

講究,這將在iOS 5

+0

yeap,它的作品) – RomanHouse 2012-08-17 07:51:32

+0

熱門答案!但只是一個額外的評論 - 請檢查參考 - 他們建議使用「應用程序:didFinishLaunchingWithOptions:」。請參閱:http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html – user387184 2012-08-17 08:08:57

1

只工作如果您使用此一個UIViewController內剛剛創建自己的子類MyUIViewController,你可以在你創建的每個新的屏幕使用它。只需使用MyUIViewController作爲屏幕的超類而不是普通的UIViewControler。

一般來說,這是一個好主意,因爲只需在MyUIViewController中更改代碼,就可以輕鬆地將其他行爲添加到所有屏幕。

相關問題