1

UINavigationController 푸시/팝 기반 탐색의 전환 애니메이션을 UIViewController의 표시/재생을 시뮬레이트하는 방식으로 사용자 정의하려고합니다. 녹색 화면에사용자 정의 "모달"애니메이션과 같은 UIViewController

  • 푸시,
  • 현재 모달 오렌지 화면,
  • 기각 모달 오렌지 스크린과
  • 팝업 : 여기

    은 표준 애니메이션의 예
    시안 화면으로 돌아 가기.

    enter image description here

나는 같은를 얻을 UIStoryboardSegue 사용자 정의 수직을 구현하는 푸시 애니메이션 "아래에서 위로 밀어"할 수 있었다.

어려운 부분은 대응하는 팝 애니메이션을 구현하는 것입니다. 내가 얻을 수있어 가장 좋은는 않습니다 : 당신이 있음을 알 수있는 이전 애니메이션에서

enter image description here

: 여기

enter image description here

은 슬로우 모션 같은 효과의 버전입니다 Bubblegum 화면이 위에서 아래로 움직여서는 안되기 때문에 표준 모달을 닫으려면 주로 애니메이션과 다릅니다. 그러나 해군 스크린 뒤에는 이미 있어야합니다. 팝. 답변과 의견에 미리

class FakeModalNavigationController: UINavigationController { 

    fileprivate static let unwindToBubblegumScreenSegueID = "unwindToBubblegumScreenSegueID" 

    override func unwind(for unwindSegue: UIStoryboardSegue, towardsViewController subsequentVC: UIViewController) { 
     if unwindSegue.identifier == type(of: self).unwindToBubblegumScreenSegueID { 
      popViewControllerAnimatedFromBottom(subsequentVC) 
     } 
    } 

    fileprivate func popViewControllerAnimatedFromBottom(_ viewControllerToPop: UIViewController) { 
     let transition = CATransition() 
     transition.duration = 0.25 
     transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) 
     transition.type = kCATransitionPush 
     transition.subtype = kCATransitionFromBottom 
     view.layer.add(transition, forKey: nil) 
     popViewController(animated: false) 
    } 
} 

감사 :

이 내가 가짜 모달 애니메이션을 기각 만드는 데 사용했던 코드입니다!

답변

2

한번에 사용하기 :

transition.type = kCATransitionReveal 
transition.subtype = kCATransitionFromBottom 
+0

덕분에,이 이전보다 훨씬 낫다) 를 불행하게도, 나는 가짜가 해군 화면의 모달을 기각 수행하면서, 여전히 풍선 껌 화면을 통해 어두운 그림자 효과가있다. 그것을 제거하는 방법을 알고 있습니까? – horothesun

관련 문제