2017-03-13 1 views
1

저는 스토리 보드에서 몇 가지 표준 세그와 함께 작업하고 있으며 각각 동일한 배경색을 사용합니다. 내가 겪고있는 문제는 segue transition이 완료 될 때 전체 프레임 주위에 어두운 그림자가 나타납니다.스위프트 세그 전이 섀도우

Image showing transition

그것은 매우 희미하지만, 문제를 일으킬 정도입니다. 누구도 전에 이것을 보았습니까?

+0

예. 떠나는 뷰 컨트롤러가 움직이는 순간입니다. 밀어 넣기와 선물 사용. 아래쪽에서 컨트롤러를 모달로 표시하는 경우가 아닙니다. – user7684436

+0

뷰 관점에서 볼 때, 뷰어가 뷰잉 컨트롤러의 그림자 오버레이를 미학을 위해 추가하는 것처럼 보인다. 그것을 제거하는 방법을 모르겠습니다. – user7684436

+0

예, 표준 푸시/팝은 사용자가 누르고있는 뷰와 팝업하려는 뷰를 어둡게 만듭니다. 당신이 그것을 좋아하지 않는다면, 당신은 아마 당신 자신의 커스텀 네비게이션 컨트롤러 애니메이션을 정의해야 할 것입니다. – Rob

답변

3

표준 탐색 컨트롤러 푸시/팝 애니메이션은 사용자가 누르고있는 뷰와 팝핑하려는 뷰를 어둡게 만듭니다. 당신이 마음에 들지 않으면, 당신은 그냥과 전망을 슬라이드 애니메이션을 사용하여 전환을 사용자 정의, 아무것도하지만의 조광하지 않습니다 수 있습니다

// this is the view controller you are pushing from 

class ViewController: UIViewController { 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     navigationController?.delegate = self 
    } 

} 

// make the view controller conform to `UINavigationControllerDelegate` 

extension ViewController: UINavigationControllerDelegate { 
    func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { 
     return PushPopAnimator(operation: operation) 
    } 
} 

// The animation controller 

class PushPopAnimator: NSObject, UIViewControllerAnimatedTransitioning { 
    let operation: UINavigationControllerOperation 

    init(operation: UINavigationControllerOperation) { 
     self.operation = operation 
     super.init() 
    } 

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

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

     let rightTransform = CGAffineTransform(translationX: transitionContext.containerView.bounds.size.width, y: 0) 
     if operation == .push { 
      to.view.transform = rightTransform 
      transitionContext.containerView.addSubview(to.view) 
      UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { 
       to.view.transform = .identity 
      }, completion: { finished in 
       transitionContext.completeTransition(!transitionContext.transitionWasCancelled) 
      }) 
     } else if operation == .pop { 
      to.view.transform = .identity 
      transitionContext.containerView.insertSubview(to.view, belowSubview: from.view) 
      UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { 
       from.view.transform = rightTransform 
      }, completion: { finished in 
       from.view.transform = .identity 
       transitionContext.completeTransition(!transitionContext.transitionWasCancelled) 
      }) 
     } 
    } 
} 

하는 뷰 컨트롤러와 사용자 전환에 대한 자세한 내용은 WWDC 참조 2013 video Custom Transitions Using View Controllers.

+0

감사합니다. 응답이 필요한 사람을 위해 기본 세그먼트로 애니메이션을 변경했습니다. Segue는 내가 가지고있는 네비게이션 바를 고려하지 않고 64pt를 위로 이동합니다. 이 문제를 해결할 방법이 있습니까? – user7684436

+0

네,'animate (withDuration : ...)'매개 변수를 원하는대로 변경할 수 있습니다. 당신이 편집 과정에서'PushPopAnimator' 클래스 정의를 날려 버렸기 때문에 편집을 거부했습니다. 그러면 사용자 정의 화면 전환에 익숙하지 않은 사람들이이 대답을 이해하기가 어려울 것입니다. 그것은 그만큼 힘들다 ...;) – Rob

+0

걱정할 필요가 없다. 당신의 도움을 주셔서 감사합니다. – user7684436