使用Xcode 8.3.1将代码更新为Swift3.1时出现此错误
'M_PI'已弃用:请使用'Double.pi'或'.pi'获取正确类型的值并避免投射.
我的代码在下面,
let center = containerShapeView.center let startAngle = CGFloat(0.0) let endAngle = CGFloat(M_PI*2) let radius = containerShapeView.bounds.width * 0.21
CGFloat(M_PI*2)行给出错误
我该如何解决?
好吧,请按照错误消息的说明操作:
let center = containerShapeView.center let startAngle = CGFloat(0.0) let endAngle = CGFloat(Double.pi) * 2 let radius = containerShapeView.bounds.width * 0.21
或者更好的是,避免不必要的转换:
let center = containerShapeView.center let startAngle: CGFloat = 0 let endAngle = CGFloat.pi * 2 let radius = containerShapeView.bounds.width * 0.21