Reputation: 133
im having some trouble with the bodyWithEdgeLoopFromPath: method in swift. i want to make a simple circle that acts as a border. I found this http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=10798 but its obj-c. any ideas ?
i also tried this piece of code
var path = CGPathCreateMutable();
CGPathAddArc(path, nil, 0, 0, 45, 0, M_PI*2, true);
CGPathCloseSubpath(path);
but i get the error 'init' is not convertible to 'CGFloat'
thanks!
Upvotes: 1
Views: 267
Reputation: 64644
The function you are using takes CGFloats, so make sure you are passing those in. You can create CGFloats using CGFloat()
, which can take a numeric literal and some numeric types.
var path = CGPathCreateMutable();
CGPathAddArc(path, nil, CGFloat(0), CGFloat(0), CGFloat(45), CGFloat(0), CGFloat(M_PI*2), true);
CGPathCloseSubpath(path);
A look at the function definition shows which arguments need to be CGFloats.
func CGPathAddArc(path: CGMutablePath!, m: UnsafePointer<CGAffineTransform>, x: CGFloat, y: CGFloat, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
Upvotes: 3