Animating with Uiimageview

Source: Internet
Author: User

  1. The first step is to create a Uiiimageview object in storyboard.

    @property (strong,nonatomic) Iboutlet uiimageview *tomimageview;

  2. The second step creates an array of pictures.

    // Create an array of images

    nsmutablearray *tomimages = [nsmutablearrayArray ];

    // path of the picture

    nsstring *imagename = [nsstringstringwithformat: @ "%@_%02d.jpg" , filename,i];

    // This method has a memory overflow and is generally not used

    //UIImage *image = [UIImage imagenamed:imagename];

    // This method does not have memory overflow

    nsstring *path = [[nsbundlemainbundle] Pathforr Esource: imageNameofType:nil];

    UIImage *image = [UIImageimagewithcontentsoffile:p Ath];

    [tomimages addobject: image];


  3. The
  4. third adds a picture array to the Uiimageview object.

        // add an array of animation execution

        [ self . tomimageview setanimationimages :tomimages];


  5. The
  6. sets the execution time for this animation.

         // Add time for animation execution

        [ self tomimageview setanimationduration : Self tomimageview animationimages count * 0.1


  7. Sets the number of times the animation executes.

    // Add the number of animation executions

    [self. Tomimageview setanimationrepeatcount:1];


  8. Start animation

    // start animation

    [self. Tomimageview startanimating];


  9. Releases the memory occupied by the animated picture.

    // method One , empty the array

    //[Self.tomimageview Performselector: @selector (clearimage) Withobject:nil afterDelay:self.tomImageVi Ew.animationduration];

    // method Two , reset setanimationimages

    [self. Tomimageview performselector:@selector(setanimationimages:)withobject : Nil afterdelay:self. Tomimageview . animationduration ];

    -(void) clearimage {

    self. Tomimageview . animationimages = Nil ;

    }



Animating with Uiimageview

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.