I'm working on a project in which I need to rotate a UIView
either clockwise or counterclockwise. However, the view only rotates clockwise.
var clockwise = false // This is a placeholder for testing
var cgFloat : CGFloat!
if clockwise {
cgFloat = CGFloat(Double.pi)
} else {
cgFloat = -CGFloat(Double.pi)
}
print ("clockwise \(clockwise) \(cgFloat)")
UIView.animate(withDuration: 2.0, animations: {
self.myView.transform = self.myView.transform.rotated(by: cgFloat)
})
The value of cgFloat
is always negative, however the view only rotates clockwise.
The console prints this value, so the CGFloat is negative: clockwise false Optional(-3.14159265358979)