如何在 UINavigationBar 中设置渐变颜色?我使用此代码在导航栏上设置色调颜色,但它不显示渐变颜色。
picker.navigationBar.tintColor = [[UIColor alloc]initWithRed:216.0/255.0 green:216.0/255.0 blue:216.0/255.0 alpha:1.0];
如何在 UINavigationBar 中设置渐变颜色?我使用此代码在导航栏上设置色调颜色,但它不显示渐变颜色。
picker.navigationBar.tintColor = [[UIColor alloc]initWithRed:216.0/255.0 green:216.0/255.0 blue:216.0/255.0 alpha:1.0];
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];
试试这个希望这会有所帮助
在 iOS 5 中
if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0 ) {
// Create resizable images
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
[[UINavigationBar appearance] setTintColor:yourColor];
}