CAGradientLayer *_bottomGradient = [CAGradientLayer layer];
// _bottomGradient.frame = CGRectMake(20, 20, 340, 340);
// UIColor *colorOne = [UIColor colorWithRed:(255.0/255.0) green:(255.0/255.0) blue:(255.0/255.0) alpha:0];
// UIColor *colorTwo = [UIColor colorWithRed:(255.0/255.0) green:(255.0/255.0) blue:(255.0/255.0) alpha:1];
// NSArray *colors = [NSArray arrayWithObjects:(id)colorOne.CGColor, colorTwo.CGColor, nil];
// _bottomGradient.colors = colors;
// _bottomGradient.startPoint = CGPointMake(0.5, 0);
// _bottomGradient.endPoint = CGPointMake(0.5, 1);
//
// //为透明度设置渐变效果
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 340, 340)];
// [view.layer insertSublayer:_bottomGradient atIndex:0];
// [self.view addSubview:view];
网友评论