我希望有一个时间倒计时指示器,就像一个圆圈一样,从一段拱形开始到一个完整的圆圈。
我尝试了几种方法,最后都是把拱门直接转成一整圈,而不是顺时针转。演示图片如下所示:
任何想法?不胜感激!
SetNeedsDisplay 当你改变其中一个角度时,你可以做一些优化,只重画受影响的区域。将这样的东西放入视图的绘制函数中。祝你好运
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGPoint center = { self.bounds.size.width * 0.5f, self.bounds.size.height * 0.5f };
CGContextClearRect(myContext, rect);
CGContextMoveToPoint(myContext, center.x, center.y);
// start and end are in radians.
CGContextAddArc(myContext, center.x, center.y, MIN(self.frame.size.width,self.frame.size.height)*0.5f, _startAngle, _endAngle, NO);
CGContextAddLineToPoint(myContext, center.x, center.y);
CGContextClip(myContext);
CGContextSetFillColorWithColor(myContext,[UIColor redColor].CGColor);
CGContextFillRect(myContext, self.bounds);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)