SwiftyTabBarTransition 1.5.3

SwiftyTabBarTransition 1.5.3

Sahand RS维护。



  • shndrs

SwiftyTabBarTransition

SwiftyTabBarTransition codebeat badge swift-version Version Platform License Carthage Compatible cocoapods

示例

要运行示例项目,请克隆仓库,然后首先从示例目录中运行 pod install

leftToRight scaleInXY

如何使用

为了享用这个框架,您有三个简单的步骤

第1步

首先,在您的 UITabBarController 类顶部导入 SwiftyTabBarTransition

import SwiftyTabBarTransition

第2步

然后,在您的 UITabBarControllerviewDidLoad() 方法中,使 delegate 等于 self,很简单,对吧?😉

class TabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        delegate = self
    }
    
}

第3步

你的 UITabBarController 类,需继承自 UITabBarControllerDelegate 协议,因此扩展你的 UITabBarController 类,然后从 animationControllerForTransitionFrom 方法进行确认

extension TabBarController: UITabBarControllerDelegate {
    
    func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        
        let transitionOptions = SwiftyTabBarTransitionOptions(duration: 0.3, animationOption: .bottomToTop)
        let transition = SwiftyTabBarTransition.set(transition: transitionOptions)
        return transition
    }
}

创建一个 SwiftyTabBarTransitionOptions 对象。此类有2个属性

  • duration

这是转换的持续时间

  • animationOption

表示转换动画的样式

动画选项

这是一个用于改变转换动画的 enum

animationOption
.scaleX
.scaleY
.scaleInXY
.scaleOutXY
.rightToLeft
.leftToRight
.topToBottom
.bottomToTop
.fade
.topLeftToBottomRight
.bottomLeftToTopRight

更多动画

scaleX topLeftToBottomRight

要求

iOS 9.3+

Xcode 10.2.1

Swift 5

安装

SwiftyTabBarTransition 可通过 CocoaPods 使用。要在最新版本中安装,只需将以下行添加到您的 Podfile 中

Swift 4.2

pod 'SwiftyTabBarTransition', '~> 1.0.2'

Swift 5.0

pod 'SwiftyTabBarTransition', '~> 1.5.3'

要使用Carthage获取库的最新版本,您可以在Cartfile中添加以下行。

Swift 4.2

github "shndrs/SwiftyTabBarTransition" "1.0.2"

Swift 5.0

github "shndrs/SwiftyTabBarTransition" "1.5.3"

作者

[email protected][email protected]shndrs

许可证

SwiftyTabBarTransition遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。