Ios 从导航栏/选项卡栏中删除光泽/渐变效果

Ios 从导航栏/选项卡栏中删除光泽/渐变效果,ios,uinavigationbar,uicolor,Ios,Uinavigationbar,Uicolor,我想消除UINavigationBar和UITabBar中出现的渐变效果。下图显示了一个使用7/29/88 RGB自定义UIColor的示例选项卡栏,该选项卡栏使用setTintColor:color设置,如您所见,选项卡栏的上半部分有光泽 如何删除此项?不可能。但是,您可以使用自定义背景图像。检查UI外观文档这是不可能的。但是,您可以使用自定义背景图像。查看UIAppearance文档如果我从导航栏中删除渐变效果,您可以尝试此代码,看看它是否也适用于您 //First, create your

我想消除UINavigationBar和UITabBar中出现的渐变效果。下图显示了一个使用7/29/88 RGB自定义UIColor的示例选项卡栏,该选项卡栏使用setTintColor:color设置,如您所见,选项卡栏的上半部分有光泽


如何删除此项?

不可能。但是,您可以使用自定义背景图像。检查UI外观文档

这是不可能的。但是,您可以使用自定义背景图像。查看UIAppearance文档

如果我从导航栏中删除渐变效果,您可以尝试此代码,看看它是否也适用于您

//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);
}

我删除了我的导航栏的渐变效果,你可以试试这个代码,看看它是否也适合你

//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);
}

取决于您对移除的定义。在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];

取决于您对移除的定义。在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];

我应该从文件中确定这一点——不知怎么的,我确信自己做错了什么!谢谢你的推荐。干杯。检查本教程。另一个选项是使用PrettyKit,在Github上查找。可以轻松消除UITabBar和UINavigationBar上的标准填充效果。请参见my answer.UIAppearance,它只是为外观代理范围内的所有实例设置特定属性值的一种方便方式。任何可以用UIAppearance做的事情都可以不用它。我同意大多数人都希望使用UIAppearance,但它绝对是可选的,不需要回答这个特定的问题。我应该从文档中确定这一点——不知何故,我确信自己做错了什么!谢谢你的推荐。干杯。检查本教程。另一个选项是使用PrettyKit,在Github上查找。可以轻松消除UITabBar和UINavigationBar上的标准填充效果。请参见my answer.UIAppearance,它只是为外观代理范围内的所有实例设置特定属性值的一种方便方式。任何可以用UIAppearance做的事情都可以不用它。我同意大多数人都希望使用UIAppearance,但它绝对是可选的,不需要回答这个特定的问题。