2011-08-03 62 views
1

我一直在尋找一種方法來自定義UIKit的UITabBarController。我想更改背景圖片和選定的色調顏色,以遵循我們的創意團隊的設計。看起來好像背景顏色可以像這裏描述的那樣改變Changing Tint/Background color of UITabBarObjective-C:自定義TabBar UITabBarController

但是,我還沒有找到一種方法將背景更改爲圖像,並將默認的「藍色」色調更改爲另一種顏色。有在AppStore許多應用程序,其使用自定義tabbars像這樣:

http://itunes.apple.com/th/app/project-noah/id417339475?mt=8

請幫助。謝謝。

回答

0

它不是的UITabBarController在這個環節

http://itunes.apple.com/th/app/project-noah/id417339475?mt=8

它的一個UIToolbar。

你可以通過創建一個類別UIToolBar

@interface UIToolBar(CustomImage) 
- (void)drawRect:(CGRect)rect; 
@end 


@implementation UIToolbar (CustomImage) 
- (void)drawRect:(CGRect)rect { 
    UIImage *image = [UIImage imageNamed: @"imageToolbar.png"]; 
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; 
    [super drawRect:rect]; 
} 
@end 
+0

謝謝你做到這一點。我是否需要顯式調用drawRect方法? drawRect方法不會自動執行,並且圖像不顯示。 – user855723

+0

我已經編輯了上面的代碼..實際上我忘了把'[super drawRect:rect];'放在函數的最後。 – Hisenberg

+0

不,你必須明確地稱呼它。 – Hisenberg