小编Ily*_*hka的帖子

没有动画的自定义视图控制器演示

我有一些自定义模式呈现和自定义控制器要呈现(UIViewController 的子类)。它是它自己的转换委托,并返回一些动画转换对象和表示控制器。我使用动画过渡对象在呈现时将呈现的视图添加到容器视图,并在关闭时将其删除,当然还可以对其进行动画处理。我使用演示控制器添加一些辅助子视图。

public final class PopoverPresentationController: UIPresentationController {
    private let touchForwardingView = TouchForwardingView()

    override public func presentationTransitionWillBegin() {
        super.presentationTransitionWillBegin()
        self.containerView?.insertSubview(touchForwardingView, atIndex: 0)
    }
}

public final class PopoverAnimatedTransitioning: NSObject, UIViewControllerAnimatedTransitioning {

    func setupView(containerView: UIView, presentedView: UIView) {
        //adds presented view to container view 
    }

    public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        //1. setup views 
        //2. animate presentation or dismissal
    }
}

public class PopoverViewController: UIViewController, UIViewControllerTransitioningDelegate {

    init(...) {
        ...
        modalPresentationStyle = .Custom
        transitioningDelegate = self
    }

    public func animationControllerForPresentedController(presented: UIViewController, presentingController …
Run Code Online (Sandbox Code Playgroud)

uikit uiviewanimationtransition ios presentviewcontroller uipresentationcontroller

5
推荐指数
1
解决办法
1923
查看次数