I run this code on simulator and device with iOS 15 but when I scroll the List items overlap navigation bar title. but I found that if I add a padding-top with 1 on the List then the view works correctly!
struct ContentView: View {
var body: some View {
NavigationView{
VStack{
List {
ForEach(1...100 , id:\.self) { index in
Text("Message \(index)")
.listRowBackground(Color.clear)
}
}
.background(
ZStack{
Image("chat_bg")
.resizable()
.opacity(0.25)
LinearGradient(gradient: Gradient(colors: [Color.black.opacity(0.9),
Color.blue.opacity(0.6)]),
startPoint: .top,
endPoint: .bottom)
}
)
.listStyle(PlainListStyle())
SendContainer(message: "")
}
.layoutPriority(1)
.navigationBarTitle(Text("Chats"), displayMode: .inline)
}
}
}
struct SendContainer:View{
@State
var message: String
var body: some View{
HStack{
Image(systemName: "paperclip")
.font(.system(size: 24))
.foregroundColor(Color.gray)
TextField("Type Text Here .... ",text:$message)
.cornerRadius(16)
Image(systemName: "mic")
.font(.system(size: 24))
.foregroundColor(Color.gray)
Image(systemName: "arrow.up.circle.fill")
.font(.system(size: 24))
.foregroundColor(Color.blue)
}
.frame(height: 48)
.padding(8)
.background(Color.white.ignoresSafeArea())
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}