简体   繁体   English

动画子视图

[英]Animate subviews

My question is really easy. 我的问题真的很简单。 I just can't figure it out how to animate between subviews. 我只是不知道如何在子视图之间建立动画。

Here's how I'm animating between VC's. 这是我在VC之间进行动画制作的方式。

I'm using Hero transitions for Swift 我正在为Swift使用Hero过渡

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
            let main = segue.destination as! ViewController
            main.hero.modalAnimationType = .selectBy(presenting: .zoomSlide(direction: .left), dismissing: .zoomSlide(direction: .right
                ))
}

This is how I'm presenting subview 这就是我呈现子视图的方式

self.view.addSubview(featureView!)

You can use one of the view transition functions like transition(with:duration:options:animations:completion:) or transition(from:to:duration:options:completion:) . 您可以使用视图过渡功能之一,例如transition(with:duration:options:animations:completion:)transition(from:to:duration:options:completion:) The one with an animations parameter takes a closure that actually performs the transition animation. 一个带有animations参数的参数需要一个实际上执行过渡动画的闭包。

The second one that does not take an animations parameter is simpler, and does the transition for you using options flags that you specify. 第二个不带有animations参数的参数更简单,它使用您指定的选项标志为您进行过渡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM