_redView是需要添加动画的view
NSString *subtypeString; subtypeString = kCATransitionFromLeft; [self transitionWithType:@"oglFlip" WithSubtype:subtypeString ForView:_redView]; - (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view { //创建CATransition对象 CATransition *animation = [CATransition animation]; //设置运动时间 animation.duration = 2; animation.repeatCount = 100; //设置运动type animation.type = type; if (subtype != nil) { //设置子类 animation.subtype = subtype; } //设置运动速度 animation.timingFunction = UIViewAnimationOptionCurveEaseInOut; [view.layer addAnimation:animation forKey:@"animation"]; }