2013-04-07 106 views
1

我想要移除發生在UINavigationBarUITabBar中的漸變效果。下圖顯示了使用7/29/88(RGB)的自定義UIColor的示例標籤欄,使用setTintColor:color進行設置,如您所見,標籤欄在欄的上半部分有光澤。從導航/選項卡欄中刪除光澤/漸變效果

enter image description here

我如何刪除呢?

回答

2

這是不可能的。但是,您可以使用自定義背景圖像。檢查UIAppearance文檔

+0

我應該從文檔中確定這一點 - 不知怎的,我相信自己我做錯了什麼!感謝您的參考。乾杯。 – Federer 2013-04-07 18:10:31

+1

查看本教程http://www.raywenderlich.com/21703/user-interface-customization-in-ios-6。另一種選擇是使用PrettyKit,在Github上查找。 – Shmidt 2013-04-07 18:43:23

+1

可以輕鬆消除「UITabBar」和「UINavigationBar」上的標準填充效果。看到我的答案。 – XJones 2013-10-19 20:47:07

2

我從我的導航欄中刪除漸變效果,你可以試試這個代碼,看看它是否適合你。

//First, create your own Navigation Bar Class, and add this to your init method. 

self.tintColor = [UIColor clearColor]; 
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yourImage"]]; 

//Add this to your DrawRect method 
- (void)drawRect:(CGRect)rect { 
    UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yourImage"]]; 
    //If you want a plain color change this 

    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColor(context, CGColorGetComponents([color CGColor])); 
    CGContextFillRect(context, rect); 
} 
6

取決於您的「刪除」的定義。在iOS 6.x(沒有測試iOS 4/5)下面的作品。

// this will show a tab bar with a solid background color 
tabBar.backgroundImage = [UIImage new]; 
tabBar.backroundColor = [UIColor blueColor]; 

// this will show a navigation bar with a solid background color 
[navBar setBakgroundImage:[UIImage new] 
      forBarMetrics:UIBarMetricsDefault]]; 
navBar.shadowImage = [UIImage new]; 
navBar.backgroundColor = [UIColor blueColor]; 
navBar.tintColor = [UIColor blueColor];