1

UINavigationBarでグラデーションカラーを設定するにはどうすればよいですか?ナビゲーションバーで色合いの色を設定するこのコードを使用しましたが、グラデーションの色が表示されません。

picker.navigationBar.tintColor = [[UIColor alloc]initWithRed:216.0/255.0 green:216.0/255.0 blue:216.0/255.0 alpha:1.0]; 
4

2 に答える 2

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];

これを試してください これが役立つことを願っています

于 2012-05-18T05:41:42.280 に答える
-1

iOS 5 で

if ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0 ) {
    // Create resizable images
    [[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
    [[UINavigationBar appearance] setTintColor:yourColor];
}
于 2012-05-18T05:43:10.593 に答える