如何在UINavigationBar中设置渐变颜色? 我在navigationBar上使用了这个设置色调颜色的代码,但它没有显示渐变色。
picker.navigationBar.tintColor = [[UIColor alloc]initWithRed:216.0/255.0 green:216.0/255.0 blue:216.0/255.0 alpha:1.0];
答案 0 :(得分:1)
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
[view.layer insertSublayer:gradient atIndex:0];
或试试这个
#import <QuartzCore/QuartzCore.h> // For .layer
self.navigationController.navigationBar.layer.contents = (id)[UIImage imageNamed:@"navigationBarBackgroundImage"].CGImage;
self.navigationController.navigationBar.tintColor = [UIColor orangeColor];
尝试这个希望,这将有所帮助
答案 1 :(得分:-1)
if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0 ) {
// Create resizable images
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
[[UINavigationBar appearance] setTintColor:yourColor];
}