1、直接通过UITabbarController.selectedindex = 1跳转页面的话,可以用下面的方法实现跳转后动画页面
var selectedViewController = UITabbarController.selectedViewController
var animation = CATransition()
animation.duration = 0.5
animation.type = kCATransitionPush//动画样式,有多种
animation.subtype = kCATransitionFromLeft
animation.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseOut)
selectedViewController.view.layer.addAnimation(animation,forKey: "switchView")//添加动画
2、点击tabbar切换页面,可以在UITabBarControllerDelegate的实现方法didSelectViewController中添加动画
func tabBarController(tabBarController: UITabBarController,didSelectViewController viewController: UIViewController) {
var animation = CATransition()
animation.duration = 0.5
animation.type = kCATransitionPush
animation.subtype = kCATransitionFromLeft
animation.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseOut)
viewController.view.layer.addAnimation(animation,forKey: "switchView")
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。