2017-05-04 93 views
0

我畫一個餅圖的用下面的代碼段:CAShapeLayer畫一個圓圈中心,線帽的sideeffect設置爲kCALineJoinRound

CAShapeLayer *segment = [CAShapeLayer layer]; 
UIBezierPath *segmentPath = [UIBezierPath bezierPath]; 

[segmentPath addArcWithCenter:segmentCenter radius:segmentRadius startAngle:angle1 endAngle:angle2 clockwise:YES]; 

segment.path = [segmentPath CGPath]; 
[segment setLineCap:kCALineJoinRound]; // this is the line which causes this 

segment.lineWidth = 8; 
segment.fillColor = [[UIColor clearColor] CGColor]; 
segment.strokeColor = [[UIColor orangeColor] CGColor]; 

[self.layer addSublayer:segment]; 

和設置kCALineJoinRound的sideffect我也弄裏面有一個小圓圈。我需要擺脫它,你能幫助我嗎?

enter image description here

回答

0

解決,以便在layoutSubviews造成此奇效被添加兩倍CAShapeLayer的問題是由於。