UIView vertical flip animation

后端 未结 8 777
温柔的废话
温柔的废话 2020-11-30 17:09

I have an iOS UIView with UIViewAnimationTransitionFlipFromRight. I need it to flip vertically though. The page curl transition won\'t cut it. I assume this wil

8条回答
  •  悲哀的现实
    2020-11-30 17:36

    Swift 5 version of @C0mrade

    func flipTransition (with view1: UIView, view2: UIView, isReverse: Bool = false) {
        var transitionOptions = UIView.AnimationOptions()
        transitionOptions = isReverse ? [.transitionFlipFromLeft] : [.transitionFlipFromRight]
    
        UIView.transition(with: view1, duration: 1.5, options: transitionOptions, animations: {
            view1.isHidden = true
        })
    
        UIView.transition(with: view2, duration: 1.5, options: transitionOptions, animations: {
            view2.isHidden = false
        })
    }
    

提交回复
热议问题