大家只要在UINavigationController的Category中push(pop)方法中調(diào)用下面這個(gè)方法就可以了
- (void)setAnimatedWithTransition{
CATransition *animation = [CATransition animation];
//動(dòng)畫時(shí)間
animation.duration = 1.0f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//過(guò)渡效果
animation.type = @"pageCurl";
//過(guò)渡方向
animation.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:nil];
}
如果只是應(yīng)用淡入淡出效果,不要navigation push的動(dòng)畫,可以將animated設(shè)置為NO,即可實(shí)現(xiàn)茴厉。
其中的動(dòng)畫類型有:
//交叉淡化過(guò)渡
animation.type = kCATransitionFade;
animation.type = kCATransitionPush;
animation.type = kCATransitionReveal;
animation.type = kCATransitionMoveIn;
animation.type = @"cameraIrisHollowOpen";
animation.type = @"cameraIrisHollowClose";
//立方體效果
animation.type = @"cube";
//收縮效果,如一塊布被抽走
animation.type = @"suckEffect";
// 頁(yè)面旋轉(zhuǎn) -上下翻轉(zhuǎn)效果
animation.type = @"oglFlip";
//水波紋
animation.type = @"rippleEffect";
//向上翻一頁(yè)
animation.type = @"pageCurl";
//向下翻一頁(yè)
animation.type = @"pageUnCurl";
注意:如果在某一個(gè)跳轉(zhuǎn)上需要加這個(gè)動(dòng)畫什荣,那就在push跳轉(zhuǎn)之前調(diào)用這個(gè)方法矾缓,切記最后一句代碼改成這樣
[self.navigationController.view.layer addAnimation:animation forKey:nil];