Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It isn't block based, but you might want to try using CAKeyFrameAnimation where you specify a few key frames that the animation needs to incorporate. The benefit versus the block based method is that the Core Animation method will allow more fluid animations.</p> <p>It may be a little overkill, because as Rob says, you can just do a CABasicAnimation and set the fromValue and toValue to 0 and 2*M_PI, respectively. But this example shows you how you could also do arbitrary rotation animations with fluid motion. </p> <p>First, make sure you add the QuartzCore Framework to your build phases. Then make sure you import the header using </p> <pre><code>#import &lt;QuartzCore/QuartzCore.h&gt; </code></pre> <p>then in your rotation method, do this:</p> <pre><code>CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animation]; theAnimation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0,0,1)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(3.13, 0,0,1)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(6.26, 0,0,1)], nil]; theAnimation.cumulative = YES; theAnimation.duration = 1.0; theAnimation.repeatCount = 0; theAnimation.removedOnCompletion = YES; theAnimation.timingFunctions = [NSArray arrayWithObjects:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil ]; [imageView.layer addAnimation:theAnimation forKey:@"transform"]; </code></pre> <p>inspired by the following: <a href="https://github.com/jonasschnelli/UIView-i7Rotate360" rel="nofollow">https://github.com/jonasschnelli/UIView-i7Rotate360</a></p> <p>Good Luck!</p> <p>t</p>
 

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