问题描述:

For the following:

struct Constants {

static let m2Pi = CGFloat(M_PI) * 2

}

SwiftLint 0.16.1 is warning me:

warning: Legacy Constant Violation: Struct-scoped constants are preferred over legacy global constants. (legacy_constant)

Note that I need this value for UIBezierPath.init(arcCenter center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool) to get a closed arc.

网友答案:

In swift 3, pi is now defined this way:

CGFloat.pi

You can also get it this way:

Double.pi 
Float.pi
相关阅读:
Top