导航栏渐变色

#import "NavigationViewController.h"

#define LBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

@interface NavigationViewController ()

@end

@implementation NavigationViewController

-(UIStatusBarStyle)preferredStatusBarStyle{

returnUIStatusBarStyleLightContent;

}

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

self.navigationBar.translucent = YES;

CAGradientLayer *gradientLayer = [CAGradientLayer layer];

UIColor *color1= LBColor(255, 70, 93);

UIColor *color2 = LBColor(251, 108, 42);

gradientLayer.colors = @[(__bridge id)color1.CGColor, (__bridge id)color2.CGColor];

gradientLayer.locations = @[@0.5, @1.0];

gradientLayer.startPoint = CGPointMake(0, 0);

gradientLayer.endPoint = CGPointMake(1.0, 0);

gradientLayer.frame = CGRectMake(0, -20, self.view.frame.size.width, 64);

[self.navigationBar.layer addSublayer:gradientLayer];

}

你可能感兴趣的:(导航栏渐变色)