2013-02-28 5 views
0

두 개의 원을 그렸습니다. 그들은 그려지지만, 그들을 연결하는 선이 있습니다. 어떻게 제거합니까? 당신은 하나의 경로에서 새, 연결되지 않은 줄을 시작하려는 경우 CGContextMoveToPoint()를 추가 할 필요가두 원 사이의 원치 않는 선 - 석영

//Background styling 
CGContextSetRGBFillColor(context, 202.0/225.0, 255.0/225.0, 112.0/225.0, 1); 

//Background setup 
background = CGRectMake(1, 1, 1024, 786);    
CGContextAddRect(context, background); 
CGContextDrawPath(context, kCGPathFill); 

//Styling 
CGContextSetLineWidth(context, 2.0); 
CGContextSetRGBStrokeColor(context, 0.0/225.0, 0.0/225.0, 225.0/225.0, 1); 
CGContextSetRGBFillColor(context, 0.0/225.0, 0.0/255.0, 225.0/225.0, 1); 

//first tower setup 
CGContextAddArc(context, 200, 150, 10, 0, 2*3.14159265359, YES); 

//second tower setup 
CGContextAddArc(context, 800, 150, 10, 0, 2*3.14159265359, YES); 

//Draw towers 
CGContextDrawPath(context, kCGPathFillStroke); 

답변

2

: 여기 내 코드입니다.

EDIT : CGContextAddArc 용 문서에 언급 된 바와 같이 :

전류 경로가 이미 서브 패스를 포함하는 경우

는 쿼츠의 시점에 현재 지점을 연결하는 선을 추가한다. 현재 경로가 비어 있다면, Quartz는 호의 시작점으로 설정된 시작점으로 새로운 새로운 서브 경로를 생성합니다.

+0

어디에 추가해야합니까? –

+0

펜을 움직이고 싶을 때. 귀하의 경우 두 개의 "AddArc"통화 사이. –

0

CGContextAddArc() 현재 경로에 이미 하위 경로가 포함되어있는 경우 Quartz는 현재 점과 호의 시작점을 연결하는 선을 추가합니다. 그래서 두 번째 CGContextAddArc() 앞에 "이동"을 추가하십시오.

CGContextMoveToPoint(context, 800+10, 150);