gpt4 book ai didi

ios - CAShapeLayer 动画颜色问题

转载 作者:行者123 更新时间:2023-11-28 21:58:51 25 4
gpt4 key购买 nike

我正在使用以下代码绘制图形:

- (void) drawCircleGraphWithPercentage:(CGFloat)percentage
{


self.circle = [[CAShapeLayer alloc] init];
self.circle.strokeColor = [UIColor whiteColor].CGColor;
self.circle.backgroundColor = [AESColorUtilities mdvdYellow].CGColor;

self.circle.lineWidth = 30.0;

// Make a circular shape
self.circle.path = self.circlePath.CGPath;


// Add to parent layer
[self.contentView.layer addSublayer:self.circle];
[self.contentView bringSubviewToFront:self.percentageLabel];

// Configure animation
CABasicAnimation* drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 1.0; // "animate over 10 seconds or so.."
drawAnimation.repeatCount = 1.0; // Animate only once..

// Animate from no part of the stroke being drawn to the entire stroke being drawn
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];

// Experiment with timing to get the appearence to look the way you want
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

// Add the animation to the circle
[self.circle addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
}

我遇到的问题是图层中有黑色形状导致颜色不正确:

enter image description here

我怎样才能使背景全是黄色“mdvdYellow”而没有背后的黑色?

提前谢谢你。

最佳答案

您需要从形状图层中移除 fillColor,因为默认为不透明黑色。

Setting fillColor to nil results in no fill being rendered.

self.circle.fillColor = nil;

关于ios - CAShapeLayer 动画颜色问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25629690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com