The first type:
Start preparing animation [UIView Beginanimations:nil Context:nil]; Set the animation time [UIView setanimationduration:2.0f]; Set the number of animations [UIView Setanimationrepeatcount:5]; Set playback (back to initial position, no by default) [UIView Setanimationrepeatautoreverses:yes]; Set the view you want to animate redview.frame = Self.window.bounds; Redview.backgroundcolor = [Uicolor Bluecolor]; Commit animation [UIView commitanimations];
The second type:
//set the range of animations uiimageview * imageview = [[ Uiimageview alloc]initwithframe:cgrectmake (10, 10, 300, 100)]; [ self.window addsubview:imageview]; //add an animated picture nsarray * imagenamearray = @[@ "1.png", @ "2.png", @ "3.png", @ "4.png"]; nsmutablearray * imageArray = [[NSMutableArray alloc]init]; for (int i = 0; i<4; i++) { UIImage *image= [UIImage imageNamed:[imageNameArray objectAtIndex:0]]; [imagearray addobject:image]; } //set playback times, not set to unlimited imageView.animationRepeatCount = 10; imageview.animationimages = imagearray; imageview.animationduration = 2; //Start Animation [imageView startAnimating]; End Animation [imageView stopAnimating];
This article from the "Network Learning Summary" blog, declined reprint!
iOS View animations