2014-02-12 134 views
-4

如何從零開始以順時針方向繪製圓弧環。我需要圓弧從0開始,並且圓弧終點可以變化。如圖所示,圖像中Circular progress在ios中以順時針方向繪製圓弧

+4

難道你費心尋找在做文檔或做任何研究?也許搜索詞「cgcontext」和「弧」?你應該能夠找到'CGContextAddArc()' –

+0

@rdurand這個問題只是一個騙局,如果OP想要動畫圓圈 –

+3

「如何從零開始順時針方向繪製弧形環」聽起來很像這樣對我.. – rdurand

回答

0

我想要的是什麼,開始從左側的弧線。( - 180)和我這樣

circular

-(void)drawRect:(CGRect)rect{ 

[super drawRect:rect]; 

CGRect customRect = rect; 
customRect.origin.x = 5; 
customRect.origin.y = 6; 
customRect.size.width = rect.size.width -10; 
customRect.size.height = rect.size.height - 12; 


radius = customRect.size.width/2 - ((customRect.size.width/2)*0.3); 


CGContextRef ctx = UIGraphicsGetCurrentContext(); 

CGContextSetRGBFillColor(ctx, 1.0, 0.0, 0.0, 1.0); 
CGContextFillEllipseInRect (ctx, customRect); 
CGContextStrokeEllipseInRect(ctx, customRect); 
CGContextFillPath(ctx); 
CGContextSetRGBStrokeColor(ctx, 0.0, 0.0, 1.0, 1.0); 
CGContextAddArc(ctx, self.frame.size.width/2 , self.frame.size.height/2, radius , -M_PI, ToRad(self.angle), 0); 

CGContextSetLineWidth(ctx, customRect.size.width/2 - (radius + 2)); 
CGContextDrawPath(ctx, kCGPathStroke); 
}