IOS

自定义NavigationController push 页面的

2018-03-04  本文已影响71人  如水的云如云的水

//MARK: Push动画

///从下向上推出(push出页面 ----> 从底部到顶部 垂直出现-消失)

funcsetPushAnimatedWithTransition(customSelf:UINavigationController) {

    if #available(iOS 9.0, *) {  }

    letanimation =CATransition.init()

     animation.duration=0.3

    animation.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionLinear)

    animation.type = kCATransitionMoveIn//kCATransitionPush

    animation.subtype = kCATransitionFromTop//kCATransitionFromTop控制类型

    customSelf.view.layer.add(animation, forKey:nil)

}

///从上向下推出(push出页面 ---> 从顶部到底部 垂直出现-消失)

funcsetPopAnimatedWithTransition(customSelf:UINavigationController) {

   if #available(iOS 9.0, *) {}

    letanimation =CATransition.init()

    animation.duration=0.3

    animation.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionLinear)

    animation.type = kCATransitionReveal//kCATransitionPush

    animation.subtype = kCATransitionFromBottom

    customSelf.view.layer.add(animation, forKey:nil)

}

//使用示例--->那个页面去push想要此效果,push前调用此方法

//setPushAnimatedWithTransition(customSelf: self.navigationController!)

//self.navigationController?.pushViewController(SelectLogController(), animated: false)//此处animated必须false

上一篇下一篇

猜你喜欢

热点阅读