我正在跟随SwiftUI tutorial使用SwiftUI创建我的第一个应用程序,但是在TVO上,我不知道为什么,但是滚动视图项的背景颜色为灰色,当它们被聚焦时它们变成白色。 我找不到改变颜色的方法...
能帮我吗?
我的代码:
struct LigneCategorie: View {
var nomCategorie: String
var items: [Recette]
var body: some View {
VStack(alignment: .leading) {
Text(self.nomCategorie)
.font(.headline)
.padding(.leading,15)
.padding(.top,5)
ScrollView(.horizontal,showsIndicators: false) {
HStack(alignment: .top) {
ForEach(self.items) { recette in
NavigationLink(
destination: RecetteDetail(
recette: recette
)
) {
CategoryItem(recette: recette)
}
}
}
}
.frame(height: 185)
}
}
}
struct CategoryItem: View {
var recette: Recette
var body: some View {
VStack(alignment: .leading) {
recette.image
.renderingMode(.original)
.resizable()
.frame(width: 200,height: 150)
.cornerRadius(10)
Text(recette.name)
.foregroundColor(.primary)
.font(.caption)
}
.padding(.leading,15)
}
}
谢谢