开发者社区> 问答> 正文

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)
}

CompleHome是另一个实现视图协议的结构:

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)
        }
    }
}

我得到了一个奇怪的结果:https://i.stack.imgur.com/R4k4V.png

我不知道为什么,但是我的Hack包含了我的两个导航链接,只有红色的矩形高.所以很难点击他..。知道为什么HStack没有好的高点吗?

展开
收起
游客5akardh5cojhg 2019-12-25 16:15:33 2044 0
1 条回答
写回答
取消 提交回答
  • 似乎缺少了填充模式。geometry

    GeometryReader{ geometry in .... }.aspectRatio(contentMode: .fill)

    2019-12-25 16:15:48
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载