SwiftUI tvOS 按钮 - 视差?

问题描述 投票:0回答:1

使用 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)
        }

}
button swiftui parallax tvos
1个回答
0
投票

您可以使用:

.buttonStyle(.card)

查看 CardButtonStyle 的文档。

© www.soinside.com 2019 - 2024. All rights reserved.