So I haven’t seen any other SO question about this. Basically, I have set a UIView with autolayout, programmatically.
The issue occurs when I try to create a UIBezierPath:
let circularPath = UIBezierPath(arcCenter: myView.center, radius: (91*(1.2))/2 - (8/2), startAngle: -CGFloat.pi / 2, endAngle: 2 * CGFloat.pi, clockwise: true)
The issue is that the myView.center prints out: 0.0, 0.0
since I did not set a CGRect .frame for the myView, and instead used autolayout (which is below):
NSLayoutConstraint.activate([
myView.heightAnchor.constraint(equalToConstant: 91),
myView.widthAnchor.constraint(equalToConstant: 91),
myView.centerXAnchor.constraint(equalToSystemSpacingAfter: myButton.centerXAnchor, multiplier: 1),
myView.centerYAnchor.constraint(equalToSystemSpacingBelow: myButton.centerYAnchor, multiplier: 1),
])
and also perhaps I should note that myView is added as a subview of myButton (though this shouldn’t really matter..)
So how do I make this work? how could I get the .center (a type CGPoint) to use in the UIBezierPath? THANKS!
Go to Source
Author: GEO G