【发布时间】:2021-11-06 15:41:11
【问题描述】:
当文本是按钮的一部分时(在 tvOS 14.7 上),这个简单的 x 偏移动画代码会导致文本也在 y 轴上移动
struct Animate: View
{
@State var scrollText: Bool = false
var body: some View {
Button(action: {}, label: {
Text("This is My Text !")
.offset(x: scrollText ? 0 : 200, y: 0)
.animation(Animation.linear(duration: 1).repeatForever(autoreverses: true))
.onAppear {
self.scrollText.toggle()
}
})
}
}
在此处查看动画行为: marquee gone wrong
如何停止 y 轴运动?
【问题讨论】:
标签: animation button swiftui marquee