相关疑难解决方法(0)

如何使用CrossDissolve幻灯片切换为Tab栏选项卡切换设置动画?

我试图在UITabBarController类似于Facebook应用程序上创建过渡效果.我设法得到一个"滚动效果"工作Tab键切换,但我似乎无法弄清楚如何交叉溶解(或它至少不起作用).

这是我目前的代码:

import UIKit

class ScrollingTabBarControllerDelegate: NSObject, UITabBarControllerDelegate {
    func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        return ScrollingTransitionAnimator(tabBarController: tabBarController, lastIndex: tabBarController.selectedIndex)
    }
}

class ScrollingTransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {
    weak var transitionContext: UIViewControllerContextTransitioning?
    var tabBarController: UITabBarController!
    var lastIndex = 0

    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return 0.2
    }

    init(tabBarController: UITabBarController, lastIndex: Int) {
        self.tabBarController = tabBarController
        self.lastIndex = lastIndex
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        self.transitionContext = transitionContext

        let containerView = …
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller uitabbar ios swift

13
推荐指数
5
解决办法
2万
查看次数

标签 统计

ios ×1

swift ×1

uitabbar ×1

uitabbarcontroller ×1