swift中tabbar切换页面动画
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") } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |