使用 Apple 的具有里程碑意义的示例代码。 我的应用程序像这样运行: https://youtu.be/CLL_oknQEDI?t=1118
但是,如何在按钮/导航链接上实现“视差”效果呢?
如果您位于焦点按钮上,则无法摆动它。就像商店中的所有其他 AppleTV 按钮一样。没有找到任何修饰符可以在按钮或导航链接上执行此操作。 我发现的只是这个论坛帖子:https://forums.developer.apple.com/thread/124684
VStack(alignment: .leading) {
Button(action: {
print("Tapped item")
}) {
landmark.image
.renderingMode(.original)
.resizable()
.frame(width: 255, height: 155)
.cornerRadius(5)
Text(landmark.name)
.foregroundColor(.primary)
.font(.caption)
}
}
您可以使用:
.buttonStyle(.card)
查看 CardButtonStyle 的文档。