[英]CAShapeLayer Animation color issue
我正在使用以下代码绘制图形:
- (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"];
}
我遇到的问题是该图层有一个黑色形状,导致颜色消失了:
我怎样才能使背景全为黄色“ mdvdYellow”而背后没有黑色?
先感谢您。
您需要从形状图层中删除fillColor
,因为默认值为不透明黑色。
将
fillColor
设置为nil
不会导致填充被渲染。
self.circle.fillColor = nil;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.