我能夠通過重寫的drawRect改變UINavigationController
的backgroung圖像:方法:如何更改UINavigationController背景顏色?
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
UIImage *img = [UIImage imageNamed: @"navController.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.tintColor = [UIColor blueColor];
}
@end
的背景是什麼,我意在與tintColor
爲好,但嘗試設置一種顏色時ISN」牛逼現有UIColor
類失敗並顯示出奇異色彩:
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
UIImage *img = [UIImage imageNamed: @"navController.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.tintColor = [UIColor colorWithRed:(26/255) green:(103/255) blue:(159/255) alpha:1];
}
@end
我怎麼能強迫UINavigationBar
顯示我想要的顏色?
注意:我只有導航控制器按鈕顏色的問題,因爲背景本身設置爲圖像。
的作品就像一個魅力!謝謝 – 4mahmoud 2012-02-15 14:33:07