[英]iPhone - How to set custom color in the “More” item's navigation bar?
全天
這是一個小細節,但確實會影響我的應用程序的專業效果。
我的應用程序遵循選項卡欄的模式,每個選項卡上都有一個導航欄,其中有5個以上的選項卡,因此是“更多”項。 我在導航欄上應用了自定義色調,但無法找到一種方法來訪問“更多”項目的導航欄以在其上設置色彩。 誰能告訴我如何?
更新中...
遵循UINavigationBar
上的類別建議,我使用了此代碼...
@implementation UINavigationBar (UINavigationBar_Additions)
- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor colorWithRed:0.862745098039216
green:0.568627450980392
blue:0.098039215686275
alpha:1];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
CGContextFillRect(context, rect);
[self setBarStyle:UIBarStyleBlack];
[self setTintColor:color];
}
@end
除了蘋果警告(出於對我而言似乎有意義的原因)關於不重寫此類隱藏方法的警告外,它還失去了UINavigationBar
上的漸變效果,我寧願保留我當前在viewDidLoad
中設置色調的方法。
關於我如何可以吃蛋糕的任何建議。
TIA,佩德羅:)
指向此博客的 StackOverflow之前已經進行了介紹,但是答案是要執行以下操作:
tabBarController.moreNavigationController.navigationBar.tintColor =
[UIColor orangeColor];
向UINavigationBar添加類別並覆蓋-drawRect :? (然后,您可以做一些有趣的事情,例如繪制圖像……)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.