点击UITabBarItem实现抖动效果

效果图:

Paste_Image.png

实现步骤

  • 导入框架文件FXAnimationTabBarController.swift,框架下载地址
    https://github.com/Guodadada/FXAnimationTabBarController
  • 创建一个继承 AnimationTabBarController 类的TabBarControllerViewController
  • 调用提供的方法添加子控制器:
tabBarControllerAddChildViewController(childView: UIViewController, title: String, imageName: String, selectedImageName: String, tag: Int)
比如:
        tabBarControllerAddChildViewController(HomeViewController(), title: "首页", imageName: "tabbar_home", selectedImageName: "v2_home_r", tag: 0)
        tabBarControllerAddChildViewController(SupermarketViewController(), title: "消息", imageName: "tabbar_message_center", selectedImageName: "v2_order_r", tag: 1)
        tabBarControllerAddChildViewController(ShopCartViewController(), title: "发现", imageName: "tabbar_discover", selectedImageName: "shopCart_r", tag: 2)
        tabBarControllerAddChildViewController(MineViewController(), title: "设置", imageName: "tabbar_profile", selectedImageName: "v2_my_r", tag: 3)

可以自定义包裹UINavigationController,比如:

let nav = UINavigationController(rootViewController: HomeViewController())
nav.navigationBar.topItem?.title = "首页"
tabBarControllerAddChildViewController(nav, title: "首页", imageName: "tabbar_home", selectedImageName: "v2_home_r", tag: 0)

注意: 此框架不适合自定义的TabBar

你可能感兴趣的:(点击UITabBarItem实现抖动效果)