UIWindow *win = [UIApplication sharedApplication].keyWindow;
[win addSubview:baseview];
self.fourview.hidden = YES;
self.twoview.hidden = NO;
self.threeview.hidden = YES;
self.oneview.hidden = YES;
添加視圖。
動畫效果:- (void)transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view
{/*
typedef enum : NSUInteger {
Fade = 1,? ? ? ? ? ? ? ? ? //淡入淡出
Push,? ? ? ? ? ? ? ? ? ? ? //推擠
Reveal,? ? ? ? ? ? ? ? ? ? //揭開
MoveIn,? ? ? ? ? ? ? ? ? ? //覆蓋
Cube,? ? ? ? ? ? ? ? ? ? ? //立方體
SuckEffect,? ? ? ? ? ? ? ? //吮吸
OglFlip,? ? ? ? ? ? ? ? ? ? //翻轉
RippleEffect,? ? ? ? ? ? ? //波紋
PageCurl,? ? ? ? ? ? ? ? ? //翻頁
PageUnCurl,? ? ? ? ? ? ? ? //反翻頁
CameraIrisHollowOpen,? ? ? //開鏡頭
CameraIrisHollowClose,? ? ? //關鏡頭
CurlDown,? ? ? ? ? ? ? ? ? //下翻頁
CurlUp,? ? ? ? ? ? ? ? ? ? //上翻頁
FlipFromLeft,? ? ? ? ? ? ? //左翻轉
FlipFromRight,? ? ? ? ? ? ? //右翻轉
} AnimationType;
*/
CATransition *animation = [CATransition animation];
animation.duration = 0.3;
animation.type = type;
if (subtype != nil) {
//設置子類
animation.subtype = subtype;
}
//設置運動速度 UIViewAnimationOptionCurveEaseInOut
//? ? animation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.2 :0.03 :0.13 :1.0];
[view.layer addAnimation:animation forKey:@"animation"];
}
視圖間切換:self.oneview.hidden = self.threeview.hidden = self.fourview.hidden = YES;
self.twoview.hidden = NO;
[self transitionWithType:kCATransitionPush WithSubtype:kCATransitionFromRight ForView:self.baseview];//切換動畫效果pus.kCATransitionFromLeft/pop
//https://github.com/dingjuanjuan/aniview/tree/master