2014-12-03 1 views
0

보기에 레이어를 그려야합니다. 그 때문에 나는이 코드를 쓴다.iOS 레이어 위치

arcLayer=[CAShapeLayer layer]; 
arcLayer.frame=self.circleView.frame; 
arcLayer.backgroundColor = [UIColor purpleColor].CGColor; 
[self.circleView.layer addSublayer:arcLayer]; 

하지만이 이미지는 다음 그림과 같이 레이어 위치가 정확한 것은 아닙니다. 녹색 하나는 circleView이고 보라색은 원호 레이어입니다.

enter image description here

+1

'arcLayer.frame = self.circleView.bounds' – user3386109

답변

3

당신은이 라인에 문제가있다 : arcLayer.frame=self.circleView.frame;. 해당 줄을 다음으로 변경하십시오.

CGRect frame = self.circleView.frame; 

frame.origin = CGPointZero; 

arcLayer.frame=frame; 

이렇게하면 문제가 해결됩니다. 레이어의 원점을 CGPointZero 또는 position으로 설정하는 것을 잊었습니다. 행운을 비네! 더 간결

0

:

arcLayer.frame = self.circleView.bounds;