2017-08-16 9 views
0

UIViewControllerをUIModalPresentationCustomで提示しているので、UIPresentationControllerも使用しています。私が提示している私のViewControllerは背景色を明確に設定しています(ストーリーボードの図では、どのビューが透明かを示すために青色に設定されています)が、白色のUIViewもあります。白と透明な背景を持つモーダルUIViewControllerを提示するときの黒のアーティファクト

storyboard picture here

私は白のビューの外側半分にある[閉じる]ボタンをタップしていたときに奇妙な何かがあります。そのボタンをタップすると、いくつかの黒いアーティファクトが表示されます。クローズボタンが画像のような位置にあり、白いビューがある場合にのみ発生します。私がボタンを上に動かすと、それは完全に白い視野にあり、黒いアーティファクトはありません。また、私はこの白いビューのために透明な色を設定するので、私のviewcontrollerはすべて透明な背景を持つので、アーティファクトはありません。

これまで誰でもこの問題がありましたか?

+0

あなたが経由で行くアイコンに精通していない場合は(フレームを自分の近くFUNCにブレークポイントを設定し、検査してみメニューのデバッグを表示>デバッグ>キャプチャビュー階層)。どのビューが黒くなっているかを確認します。それでも問題が解決しない場合は、ViewControllerのプレゼンテーションと解雇プロセスを投稿してください。 – moni15

答えて

1

@ moni15以前はビューの階層構造をデバッグしようとしていましたが、ビューのフレームをすべてオンにしているときにも黒いアーチファクトは表示されません。これはレンダリングの問題、またはiOSのバグのように見えますか?ここで

は、プレゼンテーション用のコードだと遷移をDimiss:

class TransitionPresentationAnimator: NSObject, UIViewControllerAnimatedTransitioning { 

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

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { 
     let toViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! 
     let containerView = transitionContext.containerView 

     let animationDuration = self .transitionDuration(using: transitionContext) 

     toViewController.view.transform = CGAffineTransform(scaleX: 0.1, y: 0.1) 
     toViewController.view.layer.shadowColor = UIColor.black.cgColor 
     toViewController.view.layer.shadowOffset = CGSize(width: 0.0, height: 2.0) 
     toViewController.view.layer.shadowOpacity = 0.3 
     toViewController.view.layer.cornerRadius = 4.0 
     toViewController.view.clipsToBounds = true 

     containerView.addSubview(toViewController.view) 

     UIView.animate(withDuration: animationDuration, animations: {() -> Void in 
      toViewController.view.transform = CGAffineTransform.identity 
     }, completion: { (finished) -> Void in 
      transitionContext.completeTransition(finished) 
     }) 
    } 
} 

class TransitionDismissAnimator : NSObject, UIViewControllerAnimatedTransitioning { 

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

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { 
     let fromViewController = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! 
     let animationDuration = self .transitionDuration(using: transitionContext) 

     UIView.animate(withDuration: animationDuration, animations: {() -> Void in 
      fromViewController.view.alpha = 0.0 
      fromViewController.view.transform = CGAffineTransform(scaleX: 0.1, y: 0.1) 
     }) { (finished) -> Void in 
      transitionContext.completeTransition(!transitionContext.transitionWasCancelled) 
     } 
    } 
} 

を解決しました!問題はTransitionPresentationAnimatorクラスにあり、CGAffineTransformは何か間違っていました。今はもう使用していません。 。誰もが似問題があります場合、私は私のコードを貼り付けています:

class TransitionPresentationAnimator: NSObject, UIViewControllerAnimatedTransitioning { 

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

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { 
     to = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)! 
      from = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from)! 
      let container = transitionContext.containerView 
      container.addSubview(to.view) 

      to.view.bounds.origin = CGPoint(x: 0, y: -from.view.bounds.size.height) 
      UIView.animate(withDuration: 0.6, delay: 0.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: [.curveEaseOut], animations: { 
       self.to.view.bounds = self.from.view.bounds 
      }) { (completed) in 
       transitionContext.completeTransition(completed) 
      } 
    } 
} 
関連する問題