加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift中tabbar切换页面动画

发布时间:2020-12-14 01:57:01 所属栏目:百科 来源:网络整理
导读:1、直接通过UITabbarController.selectedindex = 1跳转页面的话,可以用下面的方法实现跳转后动画页面 var selectedViewController = UITabbarController . selectedViewController var animation = CATransition () animation. duration = 0.5 animation. t

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")

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读