edgesForExtendedLayout ignored on iOS9 when using custom animation

时间秒杀一切 提交于 2019-11-29 07:57:53

this in ViewDidLoad fixes it can you confirm pls :]

self.edgesForExtendedLayout = .Top self.extendedLayoutIncludesOpaqueBars = true

You have to setup proper toViewController's frame. transitionContext.finalFrame(for:) will help you. This is my animateTransition(using:) function for fade in/out animation. That one line setting up frame will also fix your shared project.

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {

        if let toViewController = transitionContext.viewController(forKey: .to) {

            transitionContext.containerView.addSubview(toViewController.view)
            toViewController.view.frame = transitionContext.finalFrame(for: toViewController)
            toViewController.view.alpha = 0.0

            UIView.animate(withDuration: 0.5,
                           animations: {
                            toViewController.view.alpha = 1.0},
                           completion: { finished in
                            transitionContext.completeTransition(!transitionContext.transitionWasCancelled)})
        }
    }
Sparkletouch

Just setting this:

  self.edgesForExtendedLayout = UIRectEdgeTop;

Resolved the issue for me.

I know this is awful, but in viewDidLoad() i solved with this:

var frame = self.view.frame
frame.origin.y = 64 //The height of status bar + navigation bar
self.view.frame = frame

For me the problem comes out the first time my view controller is seen, when i rotate the device the problem is gone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!