通過扇形我指的是以下圖像中的效果:如何使用UIBezierPath通過動畫繪製扇形形狀?
我要顯示顏色深的動畫部分,從0到43%。任何人都可以建議這樣做的適當方式?
下面是我試過的代碼片段,但它只繪製了沒有動畫的扇形。
CABasicAnimation *bas=[CABasicAnimation animationWithKeyPath:@"strokeEnd"];
bas.duration=1;
bas.delegate=self;
bas.fromValue=[NSNumber numberWithInteger:0];
bas.toValue=[NSNumber numberWithInteger:1];
CGPoint arcCenter=self.center;
UIBezierPath *_bezierpath=[[UIBezierPath bezierPathWithArcCenter:arcCenter
radius:150
startAngle:-M_PI_2
endAngle:2*M_PI*0.5 -M_PI_2
clockwise:YES]retain];
[_bezierpath addLineToPoint:self.center];
[_bezierpath closePath];
CAShapeLayer *_shapeLayer=[CAShapeLayer layer];
_shapeLayer.fillColor=[UIColor yellowColor].CGColor;
_shapeLayer.path = _bezierpath.CGPath;
_shapeLayer.position =CGPointMake(-self.center.x+self.view.frame.size.width/2,-self.center.y+self.view.frame.size.height/2);
[self.view.layer addSublayer:_shapeLayer];
[_shapeLayer addAnimation:bas forKey:@"key"];
嘗試更加具體的?你在做什麼來創建該圖表?發佈代碼片段? –
@JosueEspinosa我添加了我的代碼。 – Dracuuula