2015-07-03 23 views
-2

圓形視圖將顯示進度,您可以看到我已經指出,圓形視圖應該劃分爲多個區域,並顯示進度達到多少百分比。 enter image description here繪製一個圓形的進度視圖,其中顯示範圍

我不知道如何處理這個設計,以及如何劃分視圖在同等範圍內,並顯示用戶已經取得了多大的進步。

任何建議和幫助將不勝感激。

感謝

+0

我已經在問題中說清楚了,我想你錯過了 - 「我不知道如何用這個設計來解決,需要幫助。」 – Vizllx

+0

提示:ProgressView,玩,看看網上的例子。這就是你學習的方式。 –

回答

2

使用兩CAShapeLayer,一個作爲背景,一個是進步

enter image description here

-(CAShapeLayer *)createCircleWithBounds:(CGRect)bounds 
          Position:(CGPoint)position 
         StrokeColor:(UIColor*)color 
          LineWidth:(CGFloat)lineWidth 
{ 
CAShapeLayer* shapelayer = [CAShapeLayer layer]; 
shapelayer.strokeColor = color.CGColor; 
shapelayer.fillColor = [UIColor clearColor].CGColor; 
shapelayer.path = [UIBezierPath bezierPathWithRoundedRect:bounds cornerRadius:CGRectGetWidth(bounds)/2].CGPath; 
shapelayer.bounds = bounds; 
shapelayer.position = position; 
shapelayer.lineCap = kCALineCapButt; 
shapelayer.lineWidth = lineWidth; 
return shapelayer; 
} 

然後

CAShapeLayer * progressLayer = [self createCircleWithBounds:CGRectMake(0, 0, 100, 100) Position:self.view.center StrokeColor:[UIColor whiteColor] LineWidth:5.0]; 
progressLayer.strokeStart = 0.2; 
progressLayer.strokeEnd = 0.8; 
[self.view.layer addSublayer:progressLayer]; 

CAShapeLayer * otherLayer = [self createCircleWithBounds:CGRectMake(0, 0, 100, 100) Position:self.view.center StrokeColor:[UIColor blueColor] LineWidth:5.0]; 
otherLayer.strokeStart = 0.2; 
otherLayer.strokeEnd = 0.5; 
[self.view.layer addSublayer:otherLayer]; 

然後,你需要做的只是使用一些數學函數改變otherLayer.strokeEnd當進度通道ange

+0

謝謝利奧.. – Vizllx

+0

如果你想要你的更新圖像,你可以使用圖像或漸變圖層作爲背景。然後使用CAShaper圖層設置maskLayer – Leo

+0

由於某些版權問題,我已經刪除了。實際上我的需要是以前的形象。我會通過你的方法,讓我看看我能得到多遠。 – Vizllx

-1

您可以使用CAShapeLayerCGPath以編程方式繪製。