1. Normal Animation:
[UIView Beginanimations:nil Context:nil];
[UIView Setanimationduration:2];
Frame.origin.x + = 150;
[img Setframe:frame];
[UIView commitanimations];
2. Continuous animation (a series of images):
Nsarray *myimages = [Nsarray arraywithobjects:
[UIImage imagenamed:@ "Myimage1.png"],
[UIImage imagenamed:@ "Myimage2.png"],
[UIImage imagenamed:@ "Myimage3.png"],
[UIImage imagenamed:@ "Myimage4.png"], nil];
Uiimageview *myanimatedview = [[Uiimageview alloc] initwithframe:[self bounds]];
Myanimatedview.animationimages = MyImage;
Myanimatedview.animationrepeatcount = 0;
[Myanimatedview startanimating];
[Self addsubview:myanimatedview];
[My Animatedview release];
3.CATransition Public API:
Catransition *animation = [catransition animation];
Animation.duration = 0.5f;
Animation.timingfunction = Uiviewanimationcurveeaseinout;
Animation.fillmide = Kcafillmodeforwards;
Various animation effects
/*
Kcatransitionfade;
Kcatransitionmovein;
Kcatransitionpush;
Kcatransitionreveal;
*/
/*
Kcatransitionfromeright;
Kcatransitionfromleft;
Kcatransitionformtop;
Kcatransitionfrombuttons;
*/
Various combinations
Animation.type = Kcatransitionpush;
Animation.subtype = Kcatransitionfromright;
[Self.view.layer addanimation:animation forkey:@ "animation"];
4.UIView Animations Animations:
[UIView beginanimations:@ "Animationid" context:nil];
[UIView setanimationduration:0.5f];
[UIView Setanimationcurve:uiviewanimationcurveeaseinout];
[UIView Setanimationrepeatautoreverses:no];
The following four kinds of effects
/*
[UIView setanimationtransition:uiviewanimationtransitionflipformleft ForView:self.view Cache:yes];
[UIView setanimationtransition:uiviewanimationtransitionflipformright ForView:self.view Cache:yes];
[UIView Setanimationtransition:uiviewanimationtransitioncurlup ForView:self.view Cache:yes];
[UIView Setanimationtransition:uiviewanimationtransitioncurldown ForView:self.view Cache:yes];
*/
5. Nesting use, first become large and then disappear
[UIView animatewithduration:1.25 aniamtions:^{
Cgaffinetransform Newtransform = Cgaffinetransformmakescale (1.2, 1.2);
[Firstimageview Settransform:newtransform];
[Secondimageview Settransform:newtransform];
completion:^ (BOOL finished) {
[UIView animatewithduration:1.2 animations:^{
[Firstimageview setalpha:0];
[Secondimageview setalpha:0];}
completion:^ (BOOL finished) {
[Firstimageview Removefromsuperview];
[Secondimageview Removefromsuperview];}
];}
];
IOS Development--animation