2013-04-07 104 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];