2017-01-19 2 views
1

私は、Transition with Left Sideから新しいView Controllerを提示しようとしています。ここにコードがあります。Transperant Background with Transition with左から右への新しいView Controllerの表示中に問題が発生しました。

@IBAction func presentNewVC(_ sender: Any) { 

     let storyBoard = UIStoryboard(name: "Main", bundle: Bundle.main) 
     let leftMenuController:NewViewController = storyBoard.instantiateViewController(withIdentifier: "NewViewController") as! NewViewController 

     leftMenuController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext 

     leftMenuController.providesPresentationContextTransitionStyle = true 
     leftMenuController.definesPresentationContext = false 

     let transition = CATransition() 
     transition.duration = 1.0 
     transition.type = kCATransitionMoveIn 
     transition.subtype = kCATransitionFromLeft 

     transition.fillMode = kCAFillModeRemoved 

     view.window!.layer.add(transition, forKey: kCATransition) 
     present(leftMenuController, animated: false, completion: nil) 

    } 

遷移中にアニメーションが実行されている間、背景の既存のビューもスライドしているように見えます。

透明な新しいビューコントローラーは、左から右に移動するように見えるのが理想的ですが、移動中は背景として既存のビューも表示するのが理想的です。

編集:ちょうどより多くの明快さを持って: それは私が探しています左から右に移動する方法をではありません。移行は&が正常に動作しています。問題は異なります。私の左メニュービューは透明で、左から右に表示している間も、トランジション中に自分自身の背景として存在する既存のビューも表示されます。 スクリーンショット&動画をご覧ください。移行中にこれを停止したいだけです。提示されている左の透明なビューだけが左から右に動くはずです。 詳細はビデオ&をご覧ください。すべてのヘルプは感謝(予想通り)enter image description here

:(問題)最後にenter image description here

:アニメーションしながら

Click here to watch video to understand the issue

答えて

1

ここは私が左から右への移行のために使ってきたものです。これはあなたが探しているものですか?

class SegueFromLeft: UIStoryboardSegue { 
override func perform() 
{ 
    let src = self.source 
    let dst = self.destination 

    src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) 
    dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0) 

    UIView.animate(withDuration: 0.25, 
        delay: 0.0, 
        options: UIViewAnimationOptions.curveEaseInOut, 
        animations: { 
        dst.view.transform = CGAffineTransform(translationX: 0, y: 0) 
    }, 
        completion: { finished in 
        src.present(dst, animated: false, completion: nil) 
    } 
    ) 
} 
} 
+0

解決策を適用しようとしました。それはクラッシュします。 ***キャッチされていない例外 'NSInternalInconsistencyException'のためにアプリケーションを終了しています、理由: '指定されたモーダルプレゼンテーションスタイルに対応するプレゼンテーションコントローラがありません。' – Niraj

関連する問題