需要在frameworks中添加QuartzCore.framework
在接口程序中加上头文件 #import <QuartzCore/QuartzCore.h>
/*好多动画效果*/
UIView动画
[UIViewbeginAnimations:@"animationID"context:nil];
[UIViewsetAnimationDuration:0.5f];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIViewsetAnimationRepeatAutoreverses:NO];
switch (theButton.tag)
{
case0:
[UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromLeftforView:self.viewcache:YES];//oglFlip, fromLeft
break;
case1:
[UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromRightforView:self.viewcache:YES];//oglFlip, fromRight
break;
case2:
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUpforView:self.viewcache:YES];
break;
case3:
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlDownforView:self.viewcache:YES];
break;
default:
break;
}
[self.viewexchangeSubviewAtIndex:1withSubviewAtIndex:0];
[UIViewcommitAnimations];
CATransition动画,公开的。
CATransition *animation = [CATransitionanimation];
//animation.delegate = self;
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
//animation.removedOnCompletion = NO;
/*
kCATransitionFade;
kCATransitionMoveIn;
kCATransitionPush;
kCATransitionReveal;
*/
/*
kCATransitionFromRight;
kCATransitionFromLeft;
kCATransitionFromTop;
kCATransitionFromBottom;
*/
switch (theButton.tag) {
case0:
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;
break;
case1:
animation.type = kCATransitionMoveIn;
animation.subtype = kCATransitionFromTop;
break;
case2:
animation.type = kCATransitionReveal;
animation.subtype = kCATransitionFromTop;
break;
case3:
animation.type = kCATransitionFade;
animation.subtype = kCATransitionFromTop;
break;
default:
break;
}
[self.view.layeraddAnimation:animation forKey:@"animation"];
CATransition动画,这些是private动画,一般还是不要用的好。
CATransition *animation = [CATransitionanimation];
animation.delegate = self;
animation.duration = 0.5f * slider.value;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.endProgress = slider.value;
animation.removedOnCompletion = NO;
switch (theButton.tag) {
case0:
animation.type = @"cube";//---
break;
case1:
animation.type = @"suckEffect";//103
break;
case2:
animation.type = @"oglFlip";//When subType is "fromLeft" or "fromRight", it's the official one.
break;
case3:
animation.type = @"rippleEffect";//110
break;
case4:
animation.type = @"pageCurl";//101
break;
case5:
animation.type = @"pageUnCurl";//102
break;
case6:
animation.type = @"cameraIrisHollowOpen ";//107
break;
case7:
animation.type = @"cameraIrisHollowClose ";//106
break;
default:
break;
}
[self.view.layeraddAnimation:animation forKey:@"animation"];