Category: Apple Computer

Getting the rotation angle after CABasicAnimation?

Getting the rotation angle after CABasicAnimation?

I had a view that I rotate a lot, often more than 360 degrees (spins around a few times). Each time it stops, I wanted to determine the resulting “visual” angle. How does one go about doing that? rotateView is a configured CABasicAnimation:

Once done, I dispatch after the randomSpeed duration so I know …

Swift 3: Distance between two CGPoints

Swift 3: Distance between two CGPoints

Here it is in Swift 3, it’s a little different. I tried to use hypotf but it didn’t like CGFloat subtraction.