我正在寻找一种动画绘制圆圈的方法.我已经能够创建圆圈,但它将所有这些组合在一起.
这是我的CircleView班级:
import UIKit
class CircleView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = UIColor.clearColor()
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func drawRect(rect: CGRect) {
// Get the Graphics Context
var context = UIGraphicsGetCurrentContext();
// Set the circle outerline-width
CGContextSetLineWidth(context, 5.0);
// Set the circle outerline-colour
UIColor.redColor().set()
// Create Circle
CGContextAddArc(context, (frame.size.width)/2, frame.size.height/2, (frame.size.width - 10)/2, 0.0, CGFloat(M_PI * 2.0), 1)
// Draw
CGContextStrokePath(context);
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我如何将其添加到视图控制器中的视图层次结构中:
func addCircleView() …Run Code Online (Sandbox Code Playgroud)