Ios-ui Base-uiimageview Frame animation

Source: Internet
Author: User

1. Create a mutable array--mutablearray, for storing, UIImage objects, pictures to animate
2. Execute a For loop
1. Stitching Picture Name
2. Instantiate a Picture object--UIImage
3. Adding a UIImage object to a mutable array

3. Assigning a variable array to the Uiimageview animationimages

Sets the picture of the last UIImage object in the array for ImageView
Set number of repetitions: Animationrepeatcount: If not set, the default is infinite loop
Set animation time: According to the number of pictures to decide

4. Turn on animations
[Animationimageview startaaimating];


Two ways to load pictures:

[UIImage imagenamed:imagestring]: cache is generated
Advantage: The next access speed back more quickly
Cons: Taking up memory space


by imagewithcontentsoffile: Loading pictures loading pictures Larger, consuming memory
Pros: No cache is generated
Cons: Slow speed

NSString *imagestring = [NSString stringwithformat:@ "%@%03d.png", name, I];

To read the file path, add the suffix of the file
NSString *path = [[NSBundle mainbundle] pathforresource:imagestring Oftype:nil];

UIImage *image = [UIImage Imagewithcontentsoffile:path];

The self call cleararraypoint parameter is nil after the delay duration time
[Self performselector: @selector (cleararraypoint) Withobject:nil afterdelay:duration];


/**
_animationimageview: After duration, execute Setanimationimages: This method, the parameter is nil
*/
[_animationimageview performselector: @selector (setanimationimages:) Withobject:nil afterdelay:duration];

Assets.xcassets: In packaging, this folder will be compressed, encrypted only through Imagenamed: Access
Footage picture, smaller than the picture


If put into bundle: imagenamed: And Imagewithcontentsoffile: All can be method
When using a picture, both JPG and PNG are prefixed with a suffix.

If you set the picture PNG by code without setting the suffix name, JPG needs to be set

Place a larger picture, welcome page

Ios-ui Base-uiimageview Frame animation

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.