【问题标题】:Circular gradient color "Not linear" in UIViewUIView 中的圆形渐变颜色“非线性”
【发布时间】:2014-12-04 12:05:13
【问题描述】:

我对渐变颜色有疑问,我无法使渐变颜色显示为圆形,它总是看起来像线性,我需要下图中的确切渐变:

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

【问题讨论】:

标签: ios objective-c uiview layer cagradientlayer


【解决方案1】:

CGContext 中有一个CGContextDrawRadialGradient。希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 1970-01-01
    • 2015-10-04
    • 2020-06-24
    • 1970-01-01
    • 1970-01-01
    • 2021-01-15
    相关资源
    最近更新 更多