我试图绘制一个简单的圆圈,但当我到达以下代码时,会出现错误:“在
startAngle = 0.0
下,Double不能转换为CGFloat。”
我尝试绘制一个简单的圆圈,但是当我到达以下行时,出现了错误“Double is Not Convertable to CGFloat under the startAngle = 0.0
”。
path.addArcWithCenter(center, radius: radius, startAngle: 0.0, endAngle: Float(M_PI) * 2.0, clockwise: true)
如何将0.0“转换”为Swift中的CGFloat?
我正在编写的完整函数:
func drawCircle() {
// Drawing code
var bounds:CGRect = secondView.bounds
var center = CGPoint()
center.x = bounds.origin.x + bounds.size.width / 2.0
center.y = bounds.origin.y + bounds.size.height / 2.0
var radius = (min(bounds.size.width, bounds.size.height) / 2.0)
var path:UIBezierPath = UIBezierPath()
path.addArcWithCenter(center, radius: radius, startAngle: CGFloat(0.0), endAngle: Float(M_PI) * 2.0, clockwise: true)
path.stroke()
}