"iOS development" about displaying a series of pictures composing animation effect Uiimageview use

Source: Internet
Author: User

A summary of the animation effects of using Uiimageview to display a bunch of pictures:

1. Create a container for this bunch of pictures, using Nsarray

Nsmutablearray *images = [Nsmutablearray array];


2 Use the Nsbudle class to load in the picture, and then each time a picture is loaded into a UIImage object, (Note: Using this class to load a picture can clear the cache, but other methods load such as

UIImage *image = [UIImage imagenamed:filename]; Method cannot clear the cache when it is loaded. )

   NSString *filename = [NSString stringwithformat:@ "%@_%02d.jpg", name, i];//        UIImage *image = [UIImage imagenamed: filename];//        [Images addobject:image];                NSBundle *bundle = [NSBundle mainbundle];        NSString *path = [bundle Pathforresource:filename Oftype:nil];        UIImage *image = [UIImage Imagewithcontentsoffile:path];
3 put each UIImage object in the collection array.

        [Images Addobject:image];

4. Assign the container array to the Animationimages property of the Uiimageview

Self.tom.animationImages = images;

5. Set the properties of the animation and start the animation

Self.tom.animationRepeatCount = 1;    Self.tom.animationDuration = Images.count * 0.08;    [Self.tom startanimating];

6 "Because every time the animation to pull the picture to load near memory, if not clear memory of useless image memory will be very high. So the way to clear the memory is

Clear picture Cache    CGFloat delay = self.tom.animationDuration + 0.05;    [Self.tom performselector: @selector (setanimationimages:) Withobject:nil Afterdelay:delay];



"iOS development" about displaying a series of pictures composing animation effect Uiimageview use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.