CABasicAnimation back to its original position after it finish it's 1 cycle
Have you tried this?
moveAnimation.fillMode = kCAFillModeForwards;
moveAnimation.removedOnCompletion = NO;
EDIT
As far as I can see you can also use animateWithDuration
which has a completion block.
Example would be:
CGRect rect = btnSpecialForListing.titleLabel.frame;
[UIView animateWithDuration:2.0 animations:^{
rect.origin.y = -7;
btnSpecialForListing.titleLabel.frame = rect;
} completion:^(BOOL finished){
[UIView animateWithDuration:3.5 animation:^{
rect.origin.x = -400;
btnSpecialForListing.titleLabel.frame = rect;
}];
}];
After rotating a CALayer using CABasicAnimation the layer jumps back to it's unrotated position
Have you set the removedOnCompletion property of the rotation animation to NO, e.g.,
rota.removedOnCompletion = NO;
That should leave the presentation layer where it was when the animation finished. The default is YES, which will snap back to the model value, i.e., the behavior you describe.
The fillMode should also be set, i.e.,
rota.fillMode = kCAFillModeForwards;
iOS animating object goes back to original position
add following lines before adding animation
animation.isRemovedOnCompletion = false
animation.fillMode = kCAFillModeForwards
Swift
animation.fillMode = .forwards
animation.isRemovedOnCompletion = false
Using CABasicAnimation to rotate a UIImageView more than once
pass incremental value of angle see my code
static int imgAngle=0;
- (void)doAnimation
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.duration = 5;
animation.additive = YES;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.fromValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(imgAngle)];
animation.toValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(imgAngle+90)];
[self.imgView.layer addAnimation:animation forKey:@"90rotation"];
imgAngle+=90;
if (imgAngle>360) {
imgAngle = 0;
}
}
Above code is just for idea. Its not tested
Related Topics
Swift Invalidate Timer Doesn't Work
How to Get a Swift Type Name as a String with Its Namespace (Or Framework Name)
Not Receiving Push Notifications from Firebase
iOS Timed Background Processing
Increment Uislider by 1 in Range 1 to 100
How to Broadcast Multiple Ibeacon Signals from Only One Bluetooth? and How
Uilabel with Two Different Color Text
Fix Cordova Geolocation Ask for Location Message
How to Get Index Path of Cell on Switch Change Event in Section Based Table View
Thread Error in Ibaction While Overriding Prepareforsegue Function
Why Force Unwrapping Is Required in Case of Enum and Switch
Open Links in Safari Instead of Uiwebview
How to Convert Uicolor Value to a Named Color String
Fatal Error: Nsarray Element Failed to Match the Swift Array Element Type