UIView *view1 =[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
[self.view addSubview:view1];
CAGradientLayer *gl = [CAGradientLayer layer];
gl.frame = view1.bounds;
gl.startPoint = CGPointMake(0, 0.5);
gl.endPoint = CGPointMake(1, 0.5);
gl.colors = @[(__bridge id)HEXCOLOR(0xFFE998).CGColor,(__bridge id)HEXCOLOR(0xFFD22F).CGColor];
gl.locations = @[@(0.0),@(1.0f)];
[view1.layer insertSublayer:gl atIndex:0];
网友评论