圓形視圖將顯示進度,您可以看到我已經指出,圓形視圖應該劃分爲多個區域,並顯示進度達到多少百分比。 繪製一個圓形的進度視圖,其中顯示範圍
我不知道如何處理這個設計,以及如何劃分視圖在同等範圍內,並顯示用戶已經取得了多大的進步。
任何建議和幫助將不勝感激。
感謝
圓形視圖將顯示進度,您可以看到我已經指出,圓形視圖應該劃分爲多個區域,並顯示進度達到多少百分比。 繪製一個圓形的進度視圖,其中顯示範圍
我不知道如何處理這個設計,以及如何劃分視圖在同等範圍內,並顯示用戶已經取得了多大的進步。
任何建議和幫助將不勝感激。
感謝
使用兩CAShapeLayer,一個作爲背景,一個是進步
例
-(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
您可以使用CAShapeLayer
和CGPath
以編程方式繪製。
我已經在問題中說清楚了,我想你錯過了 - 「我不知道如何用這個設計來解決,需要幫助。」 – Vizllx
提示:ProgressView,玩,看看網上的例子。這就是你學習的方式。 –