AnimationSwitchingTabBar 1.0.0

AnimationSwitchingTabBar 1.0.0

yysskk 维护。



  • 作者
  • K.S.Rogers

AnimationSwitchingTabBar

Version Cocoapods Carthage compatible License Platform

概览

AnimationSwitchingTabBar 是一个 Swift 中的可动画标签栏类。该项目灵感来自 dribbble 项目

alt text

使用方法

基本

定义一个标签视图控制器

继承 AnimationSwitchingTabBarController。并设置子视图控制器。

class TabViewController: AnimationSwitchingTabBarController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let vc1: AnimationSwitchingViewController = ...
        let vc2: AnimationSwitchingViewController = ...
        let vc3: AnimationSwitchingViewController = ...
        setViewControllers([vc1, vc2, vc3])
    }
}

定义子视图控制器

继承 AnimationSwitchingViewController。并设置一个图标图像。

class Child1ViewController: AnimationSwitchingViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        setIcon(image: UIImage(named: "SearchIcon"))
    }
}

实现代理

extension TabViewController: AnimationSwitchingTabBarControllerDelegate {
    override func tabBarController(_ tabBarController: AnimationSwitchingTabBarController,
                                   shouldSelect viewController: UIViewController) -> Bool {
        return true
    }

    override func tabBarController(_ tabBarController: AnimationSwitchingTabBarController, 
                                   didSelect viewController: UIViewController) {
        // Called when an tab bar controller selected the child view controller.
    }
}

其他

设置可动画图标

定义自定义项类。并配置约束和动画。

class CustomAnimatableItem: AnimationSwitchingTabBarItem {
    override func animate() {
        super.animate()
        // Define the item's animation to start.
    }
    
    override func setNotSelectedItem() {
        super.setNotSelectedItem()
        // Define constraints if the item is not selected.
    }
    
    override func setSelectedItem() {
        super.setNotSelectedItem()
        // Define constraints if the item is selected.
    }
}

需求

  • Swift 4.2 ~
  • Xcode 10.x ~

安装

CocoaPods

AnimationSwitchingTabBar 将通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile 中

pod 'AnimationSwitchingTabBar'

Carthage

您也可以通过 Carthage 进行集成。将以下行添加到您的 Cartfile

github "ks-rogers/AnimationSwitchingTabBar"

并运行 carthage update

作者

该框架由 K.S.Rogers 创建

许可

AnimationSwitchingTabBar 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。