2014-02-12 84 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); 
}