上一篇文章 說(shuō)到了翻頁(yè)的效果扣蜻,用了一種比較麻煩的方法,其實(shí)有更簡(jiǎn)單的,iOS真是只有你想不到的,沒(méi)有蘋果沒(méi)有封裝的蜻懦,
先上代碼
+ (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 交換 兩個(gè)view 在父視圖的順序丰嘉,在動(dòng)畫里執(zhí)行,就達(dá)到了下圖的效果