Swift UI 旧版本 iOS 视图不是全屏

问题描述 投票:0回答:0

注释行的那个框架不会变大,在 iOS 16 中,从导航栏到“添加注释”“TextField”的部分,但在旧版本中,如果我在该视图中放置“.frame”,我无法填充导航栏下的该空间扩展但在底部,也并且太多,“Spacer()”也没有帮助。哪里可能有问题? 这部分代码也在“NAvigationView”和“VStack”中,带有下面的按钮

               VStack {
                    Divider()
                    List {
                        ForEach(habit.aboutHabit?.components(separatedBy: "\n") ?? [], id: \.self) { description in
                            Text(description)
                        }
                        .onDelete { indices in
                            if let currentDescriptions = habit.aboutHabit?.components(separatedBy: "\n") {
                                let updatedDescriptions = currentDescriptions.enumerated().compactMap { index, description in
                                    !indices.contains(index) ? description : nil
                                }
                                habit.aboutHabit = updatedDescriptions.joined(separator: "\n")
                                try? moc.save()
                            }
                        }
                    }
                }
                     Divider()
                    Spacer()
                    HStack {
                        TextField("Add Note.", text: $aboutHabitTemp)
                            .font(.body)
                            .padding(.vertical, 9)
                            .padding(.horizontal)
                            .background(.ultraThinMaterial)
                            .cornerRadius(9)
                        Button(action: {
                            withAnimation {
                                if !aboutHabitTemp.isEmpty {
                                    if let currentDescription = habit.aboutHabit {
                                        habit.aboutHabit = "\(currentDescription)\n\(aboutHabitTemp)"
                                    } else {
                                        habit.aboutHabit = aboutHabitTemp
                                    }
                                    aboutHabitTemp = ""
                                    try? moc.save()
                                }
                            }
                        }) {
                            Image(systemName: "plus.circle.fill")
                                .foregroundColor(.primary)
                        }
                        .disabled(aboutHabitTemp.isEmpty)
                    }
                    .padding(.vertical, 9)
                    .padding(.horizontal)
                

Screenshot from view here

尝试添加框架 Maxheight .infinity,但没有任何变化,然后只是高度:350 或 450,但在底部和顶部扩展,有什么不好。

swift view frame fullscreen
© www.soinside.com 2019 - 2024. All rights reserved.