我正在尝试将a设置NavigationButton
为显示图像,而不是仅显示蓝色按钮。
目前,我正在显示Scrollview
由Images组成的Horizontal 。
这些图片应导致另一种视图,该视图将呈现在上方rootView
。
但是,当我将这些图像包裹在周围时NavigationButton
,这些图像只会变成蓝色,而不显示想要的原始图像。
类别行组件(ScrollView
)
ScrollView(showsHorizontalIndicator: false) {
HStack(alignment: .top, spacing: 0) {
ForEach(categorizeCountry()) { place in
NavigationButton(destination: PlaceDetail(place: place)) {
Image(place.imageName)
.resizable()
.clipShape(Rectangle())
.frame(width: 225, height: 150)
.cornerRadius(8)
.padding(.leading, 2)
.padding(.trailing, 2)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
ContentView(显示CategoryRow的位置)
var body: some View {
NavigationView {
List {
FeaturedCard(places: fiveRandomPlaces)
CategoryRow(label: "Australia")
CategoryRow(label: "Japan")
CategoryRow(label: "Singapore")
CategoryRow(label: "Indonesia")
ForEach(store.places) { place in
PlaceCell(place: place)
}
}
.navigationBarTitle(Text("Been There"))
.navigationBarItems(trailing: Button(action: sortPlaces) {
Text("Sort")
})
.listStyle(.grouped)
}
}
Run Code Online (Sandbox Code Playgroud)
我希望图像可以像按钮一样工作(确实如此),但是仍然显示原始图像,而不是全是蓝色。
达到预期效果和实际效果的图像如下:
Ric*_*zio 10
尝试更改渲染模式
Image(place.imageName)
.renderingMode(.original)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
299 次 |
最近记录: |