//duration //设置动画时间
//timingFunction // 动画速度,何时快、慢
//
//kCAMediaTimingFunctionLinear //线性(匀速)
//kCAMediaTimingFunctionEaseIn //先慢
//kCAMediaTimingFunctionEaseOut //后慢
//kCAMediaTimingFunctionEaseInEaseOut //先慢 后慢 中间快
//kCAMediaTimingFunctionDefault //默认
//
//type // 动画效果
//
//kCATransitionFade //淡出
//kCATransitionMoveIn //覆盖原图
//kCATransitionPush //推出
//kCATransitionReveal //底部显出来
//
//subtype //动画方向
//
//kCATransitionFromRight // 右
//kCATransitionFromLeft // 左
//kCATransitionFromTop // 上
//kCATransitionFromBottom // 下
extension UIApplication {
func cutRootVC(_ vc:UIViewController){
let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
transition.type = kCATransitionFade
transition.subtype = kCATransitionFromRight
self.keyWindow?.rootViewController = vc
self.keyWindow?.layer.add(transition, forKey: "animation")
}
}
网友评论