我正在使用SwiftUI构建tvOS应用。这是它的外观:
我希望顶部绿色标签显示当前关注的元素数。
代码如下:
Text(selection ?? "no value").background(Color.green)
和
NavigationView {
ScrollView(.horizontal) {
HStack{
VStack {
NavigationLink(destination: view2, tag: "1", selection: $selection) {
Image("placeholder").scaledToFit().frame(width:300, height: 170) }
Text("Button").foregroundColor(Color(.white)).padding(.top,10)
}
VStack {
NavigationLink(destination: view2, tag: "1", selection: $selection) {
Image("placeholder").scaledToFit().frame(width:300, height: 170) }
Text("Button").foregroundColor(Color(.white)).padding(.top,10)
}
...
}.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .bottomLeading)
}
}
我应该如何实现呢?