图像和适合度是可区分的,但是当我单击适应度时,打开图像页面。
这是我的代码:
VStack {
HStack(alignment: .center) {
NavigationLink(destination: FullNewsListView(category: "Fitness")) {
Text("Fitness")
.foregroundColor(Color("#29B1B3"))
.font(Font.custom("AvenirNextLTPro-Bold", size: 20))
Image("forward_blue")
}
Spacer()
}
.padding(.bottom, 10)
VStack(alignment: .leading, spacing: 10) {
HStack {
URLImage(URL(string: "http://myPhoto")!) { proxy in
proxy.image
.renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(minWidth: 0, maxWidth: .infinity)
.frame(height: 180)
.cornerRadius(12)
.clipped()
}
}
HStack {
Text(api.newsFitnessHome.news!.title)
.foregroundColor(.black)
.font(Font.custom("AvenirNextLTPro-Demi", size: 15))
.opacity(0.8)
.lineSpacing(5)
.lineLimit(2)
.fixedSize(horizontal: false, vertical: true)
Spacer()
}
}
}
.padding(.horizontal, 30)
无法测试,因为没有所有可用的组件,但是我想这是由于图像命中区域所致,请参阅下面的一些假设
URLImage(URL(string: "http://myPhoto")!) { proxy in
proxy.image
.renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(minWidth: 0, maxWidth: .infinity)
.frame(height: 180)
.cornerRadius(12)
.clipped()
.contentShape(Rectange()) // try this
}
//.contentShape(Rectange()) // or here
您可以尝试这种设置:
VStack {
HStack(alignment: .center) {
NavigationLink(destination: FullNewsListView(category: "Fitness")) {
HStack {
Text("Fitness")
// .foregroundColor(Color("#29B1B3"))
.font(Font.custom("AvenirNextLTPro-Bold", size: 20))
Image("forward_blue")
Spacer()
}
}
Spacer()
}.padding(.bottom, 10)
}
....
也.foregroundColor(Color(“#29B1B3”))对我不起作用。