xcode - How can I create an imageview rotate 360° infinity and smoothly in Swift? -


after spending @ least hour searching solution, have been unsuccessful. new xcode , swift struggling understand of more experienced people meaning along fact lot of answers outdated.

how can create imageview rotate 360° infinity , smoothly in swift?

i assume referring ios, every view layer-backed. makes easier add visual effects.

to start animation:

let rotation = cabasicanimation(keypath: "transform.rotation.z") rotation.byvalue = 2 * cgfloat.pi // measured in radians. positive = clockwise, negative = counter-clockwise rotation.duration = 2 rotation.repeatcount = float.greatestfinitemagnitude // forever  imageview.layer.add(rotation, forkey: "myanimation") 

to end animation:

imageview.layer.removeanimation(forkey: "myanimation") // or: imageview.layer.removeallanimations() 

adjust taste!


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -