-1

有没有一种方法可以轻松地在函数中制作可自定义的 UIModalTranstitionStyle,以便在呈现时可以为多个 viewController 自定义和重用该函数

例子:

func customTransition() -> UIModalTransitionStyle  {
        //other things here to customize transition
    }

只是标准的 .crossdissolve ,.fliphorizo​​ntal 和所有这些都不是我需要的,所以我只是想知道你是否可以,因为我用 UIView 做到了

func popIn(yourView : UIView) {

        yourView.transform = CGAffineTransform(scaleX: 0.01, y: 0.01)
        UIView.animateKeyframes(withDuration: 0.2, delay: 0.0, options: UIViewKeyframeAnimationOptions.calculationModeDiscrete, animations: {
            yourView.transform = .identity
        }, completion: nil)
        self.view.addSubview(yourView)
    }
4

1 回答 1

2

编写自定义演示转换的方法是编写自定义演示转换。这样做的过程很简单并且有据可查:

  • 设置一个transitioningDelegate

  • 实施animationController(forPresented:presenting:source:)

  • 提供一个动画控制器对象

如果您不喜欢这样(“一堆 NSObject 并编写超级复杂的东西”?),那么不要尝试自定义演示转换。相反,如果你想要一个自定义的过渡动画,那就做一个。

于 2017-09-25T17:24:56.290 回答