我第一次把脚趾伸进SwiftUI和WatchOS。我正在取得很好的进展,但我想不出如何摆脱我的图像控件两边的黑色“排水沟”。我试过把所有的背景都设置成白色,但阴沟依然存在。
我需要在哪个视图上设置更改排水沟颜色以匹配背景的属性?
SwiftUI
struct ContentView: View {
var body: some View {
List {
Image("cat-1").resizable().scaledToFill().background(Color.white)
Image("cat-2").resizable().scaledToFit().padding(5).background(Color.white)
Image("cat-3").resizable().scaledToFit().padding(.top, 5).background(Color.white)
}.background(Color.white).listStyle(CarouselListStyle())
.background(Color.white)
}
}
发布于 2022-11-27 06:05:24
尝试添加一个
.listRowPlatterColor(.clear)
像这样把它放在名单里..。
struct ContentView: View {
var body: some View {
List {
Image("cat-1")
.resizable()
.scaledToFit()
.listRowPlatterColor(.clear)
Image("cat-2").resizable().scaledToFit().padding(5).background(Color.white)
Image("cat-1")
.resizable()
.scaledToFit()
.padding(.top, 5)
.background(Color.white)
}
.listStyle(CarouselListStyle())
}
}
我把它放在第一个项目中,把它放在第二个和第三个项目上,这样你就可以看到区别了。另一个问题可以提供更多的细节:How to style rows in SwiftUI List on WatchOS?。然后,您应该能够在任何您喜欢的风格。
https://stackoverflow.com/questions/74586546
复制相似问题