CAKeyframeAnimation : contents change back to first image when stopped

uiview animate
ios image animation effect
animate uiimageview swift
swift animation
uiview slide down animation swift
uiview popup animation swift

I animate the content of a CALayer using the following code:

CAKeyframeAnimation *countanimation = [CAKeyframeAnimation animation];
NSArray *images = [NSArray arrayWithObjects:(id)[UIImage imageNamed:@"number3"].CGImage, 
                        (id)[UIImage imageNamed:@"number2"].CGImage, 
                        (id)[UIImage imageNamed:@"number1"].CGImage, nil];
[countanimation setKeyPath:@"contents"];
[countanimation setValues:images];
[countanimation setCalculationMode:kCAAnimationDiscrete];
[countanimation setDuration:3.0f];
[countanimation setDelegate:self];
[countanimation setAutoreverses:NO];
[countanimation setRemovedOnCompletion:NO];
[countanimation setValue:@"Countdown" forKey:@"name"];
[countDown addAnimation:countanimation forKey:nil];

And want to hide the layer when the animation is stopped:

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
    if([[anim valueForKey:@"name"] isEqual:@"Countdown"])
    {
        [countDown setHidden:YES];
        ...
    }
}

The problem is that the layer is flashing once with the original image (number3) and is hidden after that.

I want to know why the layer goes back to the original even though I set removedOnCompletion to NO.

You can use FillMode property in conjunction with removedOnCompletion property to set first frame back to its content after repeatCount is over.

[countanimation setFillMode:kCAFillModeBoth];
[countanimation setRemovedOnCompletion:NO];

I think this two lines of code can help you get the required result.

ios, You can use FillMode property in conjunction with removedOnCompletion property to set first frame back to its content after repeatCount is over. [​countanimation  If your concern is only reset to an image frame when the animation finished, you can achieve this by setting that frame to the .image property. UIImageView iterates over the animatedImages , when animation finished it just returns back to the previously set .image property, which will be your last image frame or whatever.

I used animation.fillMode = kCAFillModeForwards; to fix this problem

Animate Images in a UIImageView with Completion Handler, All I needed was to show a series of images in a UIImageView. the image reset to the first frame, for a brief moment, and then back to the last frame. My second attempt was to use the CAKeyFrameAnimation API. I also had to change my NSArray of images to store the CGImage instead of the UIImage. If you decrease the capacity of a scale set, the VMs with the highest instance IDs are removed first. Stop and start VMs in a scale set. To stop one or more VMs in a scale set, use Stop-AzVmss. The -InstanceId parameter allows you to specify one or more VMs to stop. If you do not specify an instance ID, all VMs in the scale set are stopped.

I replaced the original image to number1, and the problem was solved.

4. Animation - Programming iOS 7, 4th Edition [Book], Suppose your code changes it to red, and then later changes it back to green: if that fails, @"1" ) to the name you supply and makes that image file the first image in the animation sequence. You can also animate a UIView's change of contents. To stop the animation, cancel sets the view back to its original position: Applications based on larger container images like Windows Server Core can see significant improvement in deployment speed when you update instead of delete and deploy new. Limitations. Not all properties of a container group support updates. To change some properties of a container group, you must first delete, then redeploy the group.

Swift 4+5

Updating Jami's answer for Swift 4 and 5

colorAnimation.fillMode = .both
colorAnimation.isRemovedOnCompletion = false

Animation doesn't show - cocoa - iOS, So you'd have one animation to go in one direction, and once it's finished it triggers CAKeyframeAnimation : contents change back to first image when stopped. How to Stop Next Page Content from Moving When Adding Text in Word. When you compile multiple pages in a Microsoft Word document and want to keep content together on a second or subsequent page, insert a page break to help preserve the page layout.

CAKeyframeAnimation, Methods your app can implement to respond when animations start and stop. class CAPropertyAnimation. An abstract subclass of CAAnimation for creating  On your computer, go to Gmail. Click Setting Scroll to Inbox type. Select Default, Important first, Unread first, Starred first, Priority Inbox, or Multiple Inboxes. Learn about the inbox layout options. Some inbox styles have more settings and options you can change.

Chapter 17. Animation, Suppose your code changes it to red, and then later changes it back to green: You can designate an image as an animated image with one of two UIImage class methods: You can also animate a UIView's change of contents. That's because the second animation caused the first animation to be thrown away; the​  You can stop and start your instance if it has an Amazon EBS volume as its root device. The instance retains its instance ID, but can change as described in the Overview section. When you stop an instance, we shut it down.

View-Layer Synergy · objc.io, For backing layers, the search for an action doesn't go further than the first step. When a property changes inside of an animation block, the view returns a basic animation to the In fact, there isn't really anything stopping us from writing our own animation of the contents property being added to the image view's layer: Christopher Columbus - Christopher Columbus - The first voyage: The ships for the first voyage—the Niña, Pinta, and Santa María—were fitted out at Palos, on the Tinto River in Spain. Consortia put together by a royal treasury official and composed mainly of Genoese and Florentine bankers in Sevilla (Seville) provided at least 1,140,000 maravedis to outfit the expedition, and Columbus

Comments
  • I just found that these settings need to be on the group if you are using a CAAnimationGroup, rather than the individual animations, in case that helps anyone coming here