相关疑难解决方法(0)

有没有办法在 SwiftUI 中的动画之后执行函数?

在 UIKit 中,您可以执行以下操作:

UIView.animate(withDuration: TimeInterval, animations: {
    //animation
  }) { (Bool) in
    //code which will be executed after the animation
}
Run Code Online (Sandbox Code Playgroud)

SwiftUI 中有没有类似的东西,或者你能想到一个替代品吗?

ios swift swift5 swiftui xcode11

9
推荐指数
1
解决办法
708
查看次数

如何在SwiftUI中对路径进行动画处理

不熟悉SwiftUI,并且不熟悉此新框架的事实。我想知道是否有人熟悉如何Path在SwiftUI中设置动画。

例如,给定一个视图,可以这样简单地说RingView

struct RingView : View {   
    var body: some View {
        GeometryReader { geometry in
            Group {
                // create outer ring path
                Path { path in
                    path.addArc(center: center,
                                radius: outerRadius,
                                startAngle: Angle(degrees: 0),
                                endAngle: Angle(degrees: 360),
                                clockwise: true)
                }
                .stroke(Color.blue)

                // create inner ring
                Path { path in
                    path.addArc(center: center,
                                radius: outerRadius,
                                startAngle: Angle(degrees: 0),
                                endAngle: Angle(degrees: 180),
                                clockwise: true)
                }
                .stroke(Color.red)
                .animation(.basic(duration: 2, curve: .linear))
            }
        }
        .aspectRatio(1, contentMode: .fit)
    }
}
Run Code Online (Sandbox Code Playgroud)

显示的内容是:

在此处输入图片说明

现在,我想知道如何对内圈进行动画处理,即蓝线内的红线。我想要做的动画将是一个简单的动画,其中路径从头开始出现并遍历到结束。 …

animation swift swiftui

3
推荐指数
1
解决办法
1710
查看次数

标签 统计

swift ×2

swiftui ×2

animation ×1

ios ×1

swift5 ×1

xcode11 ×1