1)
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = .3f;
fullRotation.repeatCount = 1;
[self.layer addAnimation:fullRotation forKey:@"360"];
2)
if(rotationCount == 3) {
[UIView animateWithDuration:.4f delay:0.f usingSpringWithDamping:.5f initialSpringVelocity:0.f options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_2)];
} completion:^(BOOL finished) {
if (finished) {
return;
}
}];
}
else {
[UIView animateWithDuration:.2f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_2)];
} completion:^(BOOL finished) {
[self rotateAnimation];
}];
}
rotationCount++;
3)
[UIView animateKeyframesWithDuration:.8f delay:0.0 options:UIViewKeyframeAnimationOptionCalculationModeLinear|UIViewKeyframeAnimationOptionBeginFromCurrentState animations:^{
// push the from- view to the back
[UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:0.4f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_2)];
}];
[UIView addKeyframeWithRelativeStartTime:0.2f relativeDuration:0.4f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_2)];
}];
// slide the to- view upwards. In his original implementation Tope used a 'spring' animation, however
// this does not work with keyframes, so we siulate it by overshooting the final location in
// the first keyframe
[UIView addKeyframeWithRelativeStartTime:0.6f relativeDuration:0.2f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_2)];
}];
[UIView addKeyframeWithRelativeStartTime:0.8f relativeDuration:0.2f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_2)];
}];
/*
[UIView addKeyframeWithRelativeStartTime:1.f relativeDuration:0.4f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, -(M_PI_2))];
}];
[UIView addKeyframeWithRelativeStartTime:.9f relativeDuration:0.2f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, M_PI_4)];
}];
[UIView addKeyframeWithRelativeStartTime:1.4f relativeDuration:0.2f animations:^{
[_thumbnailImage setTransform:CGAffineTransformRotate(_thumbnailImage.transform, -(M_PI_4))];
}];
[UIView addKeyframeWithRelativeStartTime:1.8f relativeDuration:0.2f animations:^{
[_thumbnailImage setTransform:CGAffineTransformIdentity];
}];*/
} completion:^(BOOL finished) {
}];