我有一个代码,并创建了NavigationLink按钮,我编写了Text和Image,但是我的Image没有看到。请帮助我。
VStack{
Image("Coachs")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 370, height: 200)
//.clipped()
.cornerRadius(20.0)
NavigationLink(destination: Text("Detail view here")){
ZStack{
Text("Press on me")
.foregroundColor(.white)
.font(.largeTitle)
Image("Coachs")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 370, height: 200)
//.clipped()
.cornerRadius(20.0)
}
}}
答案 0 :(得分:3)
好吧,我查看了其他图像类型,尝试一下,它应该可以工作:
Image("IMG_4944")
.renderingMode(.original) // <----- this
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 370, height: 200)
.clipped()
.cornerRadius(20.0)
答案 1 :(得分:1)
我从您的代码进行了此测试,并且一切正常,ios 13.4和催化剂,xcode 11.4和macos catalina 10.15.4
var body: some View {
NavigationView {
VStack {
Image(systemName: "person.2.fill")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 370, height: 200)
//.clipped()
.cornerRadius(20.0)
NavigationLink(destination: Text("Detail view here")){
ZStack{
Image(systemName: "person.2.fill")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 370, height: 200)
//.clipped()
.cornerRadius(20.0)
Text("Press on me")
.foregroundColor(.black)
.font(.largeTitle)
}
}
}
}.navigationViewStyle(StackNavigationViewStyle())
}
答案 2 :(得分:1)