4

我正在尝试创建一个动画来展示和关闭一组对象。我有:

if self.showSignInButtons {
    Group {
        Button(action: {}) { ... }
        HStack { ... }
        Button(action: {}) { ... }
    }.transition(
        AnyTransition.signInButtonTransition(
        offset: geometry.size.height,
        duration: 1.4,
        delay: 50.0)
    )
}

这是自定义AnyTransition动画的定义

public extension AnyTransition {

    static func signInButtonTransition(offset: CGFloat, duration: Double, delay: Double) -> AnyTransition {
        let insertion = AnyTransition.offset(y: offset)
            .animation(Animation.easeOut(duration: duration).delay(delay))
        let removal = AnyTransition.offset(y: offset).animation(.default)
        return .asymmetric(insertion: insertion, removal: removal)
    }
}

我的目标是延迟插入动画以创建序列,但我不希望在视图被关闭时出现延迟。问题是尽管添加了动画修改器,但不对称动画仍在使用默认动画。是否有任何理由忽略插入时的延迟和持续时间动画?

4

0 回答 0