首页 文章

UIView中的圆形渐变颜色“非线性”

提问于
浏览
0

我有一个渐变颜色的问题,我不能使渐变颜色显示为圆形,它总是看起来像线性,我需要在下图中的精确渐变:

enter image description here

PS: 这是我使用的代码:

UIView *view = [[UIView alloc] initWithFrame:self.view.frame];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.startPoint = CGPointMake(0.0,0.4);
gradient.endPoint = CGPointMake(0.0,0.6);
view.layer.masksToBounds = YES;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:153.0/255.0 green:204.0/255.0 blue:0.0/255.0 alpha:1.0] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
[view.layer insertSublayer:gradient atIndex:0];
[self.view addSubview:view];

1 回答

相关问题