I I want to create two methods … StartSpin and StopSpin. In StartSpin, I need an UIImageView to spin 360 degrees and loop it until I call StopSpin.
Here’s my StartSpin so far…
private void StartSpin () {
UIView.Animate (
1,
0,
UIViewAnimationOptions.Repeat,
() => {
CGAffineTransform t = CGAffineTransform.MakeIdentity();
t.Translate(0, 0);
t.Rotate((float)(3.14));
this._imageViewWait.Transform = t;
},
() => {}
);
}
Here’s my two questions…
-
How do I make it spin 360 degrees?
-
What command should I use in StopSpin method to stop the spinning?
Thanks
Mojo
To make the image spin, you can use (rotate 1 degree):
To make the image spin, simply create a timer the continuously calls this method (and increments the degree). Also, create a bool value to keeps track if you want to keep spinning.
To stop the spin, simply change the bool value to false. Then, continue updating until you reach the beginning (the degree is 360 or 0) and the bool value is false.
If you don’t want to continue spinning until the image is back to its original position, just eliminate
&& degrees == 0In code: