上一篇文章 说到了翻页的效果,用了一种比较麻烦的方法,其实有更简单的,iOS真是只有你想不到的,没有苹果没有封装的,
先上代码
+ (void)transitformShowView:(UIView *)view hiddenView:(UIView *)toView
{
NSInteger indexView = [view.superview.subviews indexOfObject:view];
NSInteger indexToView = [toView.superview.subviews indexOfObject:toView];
[UIView beginAnimations:@"tranTwoViewAnimation" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view.superview cache:YES];
[view.superview exchangeSubviewAtIndex:indexView withSubviewAtIndex:indexToView];
[UIView commitAnimations];
}
交换了 利用 view的api 交换 两个view 在父视图的顺序,在动画里执行,就达到了下图的效果