1
我有3個導航控制器,我想改變每個背景使用不同的圖像。我實現擴展UINavigationBar的這樣的類別:更改3導航欄背景與不同的圖像
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"background.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];}
@end
但它使每一個導航欄有相同的背景圖片。然後我試圖實現這樣的代碼:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
UIImageView *backGroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.navigationController.navigationBar insertSubview:backGroundView atIndex:0];
[backGroundView release];
}
在每一個控制器,但每個背景只顯示tintColor,而不是圖像...我應該怎麼辦???
以及如何我也想在tabbarController中做到這一點?
THX羅格以下,但它仍然不會改變任何東西...任何想法? – 2010-12-02 09:35:52