Note that there are some explanatory texts on larger screens.

plurals
  1. POspin UIImageView with core animation
    primarykey
    data
    text
    <p>I am trying to make something relatively simple, make a wheel spin 90degrees when the user touches a button, for the most part what I have done so far works the first time, but thereafter the image won't move. I want it to keep its new position and rotate 90degrees thereafter from the new position, I have [UIView setAnimationBeginsFromCurrentState:YES];</p> <p>but that doesn't seem to work</p> <p>I added an NSTimer to "reset" the original image orientation, so that the wheel springs back to the original position and then rotates again when the user touches it. ... however this isn't really what I want.</p> <p>Is there a way to make the image keep rotating 90degrees so four touches by the user would put the image back to its original position. Thanks for any help!!</p> <p>here is the sample code</p> <pre><code> -(IBAction) rotatewheel:(id)sender { [UIView setAnimationDuration:1]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationRepeatCount:1]; wheel.transform = CGAffineTransformMakeRotation(M_PI/4); [UIView commitAnimations]; returnwheelTimer = [NSTimer scheduledTimerWithTimeInterval:1.1 target:self selector:@selector (returnwheel) userInfo:nil repeats:NO]; } </code></pre> <pre><code> -(void) returnwheel { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:.5]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationRepeatCount:1]; wheel.transform = CGAffineTransformMakeRotation(M_PI); [UIView commitAnimations]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload