ios - NavigationLink 似乎只占用很小的空间
问题描述
我正在使用 NavigatonView 和 NavigationLink,我的观点是这样的:
ScrollView{
VStack{
// MARK: - Survey and tips Navigation
HStack(spacing:9){
NavigationLink(destination:Container.sharedContainer.resolve(SurveyListView.self,argument: $VM.occurrences)!){
iconHome(image: "img-survey", icon: "icon-survey", text: "surveys_upper_case")}
NavigationLink(destination:Container.sharedContainer.resolve(SurveyListView.self,argument: $VM.occurrences)!){
iconHome(image: "img-tip", icon: "icon-tip", text: "tips_upper_case")}
}
.frame(maxWidth: .infinity,maxHeight: .infinity)
}
.padding(.horizontal,37)
.background(Color.red)
}
iconHome 是另一个实现视图协议的结构:
struct iconHome : View{
var image:String
var icon:String
var text:LocalizedStringKey
var body : some View{
GeometryReader{ geometry in
ZStack{
Image(self.image)
.renderingMode(.original)
.resizable()
.frame(width: geometry.size.width ,height:geometry.size.width)
.aspectRatio(contentMode: .fit)
.cornerRadius(20)
VStack{
Image(self.icon)
.renderingMode(.original)
.resizable()
.frame(width: geometry.size.width / 5,height:geometry.size.width / 5 )
.aspectRatio(contentMode: .fit)
Text(self.text)
.foregroundColor(.white)
.modifier(OpenSansBoldModifier(fontSize: 12))
}
}
.shadow(radius: 5, x: 5, y: 5)
}
}
}
我不知道为什么,但我的 HStack 包含我的两个导航链接只有红色矩形高......所以很难点击他......关于为什么 HStack 没有好的高的任何想法?
解决方案
似乎缺少填充模式geometry
GeometryReader{ geometry in
....
}.aspectRatio(contentMode: .fill)
推荐阅读
- java - 在 run 方法中创建 `Autowired`
- mosquitto - 向 vernemq 发送 mosquitto 消息
- python - Python mysql自动提交对phpmyadmin不可见的数据
- ios - 我使用wheaterapi.com 并使用init URL(字符串:urlString)创建url。链接可与浏览器一起使用,但不能与应用程序一起使用。怎么修?
- java - 使用ffmpeg作为Java中的进程录制实时流
- docker - docker容器内的dompdf:file_put_contents(x / x)无法打开流:没有这样的文件或目录
- javascript - 如何使用 Laravel 调试栏检查文件上传?
- c# - 复杂的数学表达式 c#
- delphi - QuickReport:将详细信息带和子带保持在一页上
- python - 如何使用 bs4 获取 youtube 音乐历史?