I developed a chat screen using SwiftUI. The current minimum iOS version is 13.0.
To make the chat, I use the element List with ForEach. The problem is that the list shows the dividers, and I need to hide them:
I tried to hide the style of TableView but nothing works. Here's the code:
struct MessagesView: View {
var messages: [MessageModel] = []
init() {
// To remove only extra separators below the list:
UITableView.appearance().tableFooterView = UIView()
// To remove all separators including the actual ones:
UITableView.appearance().separatorStyle = .none
}
var body: some View {
List {
ForEach(messages, id: \.messageId) { message in
Group {
if(messPack.user != nil) {
ReceivedMessageView(
message: message.message,
name: message.user?.name,
color: message.user?.color)
} else {
SentMessageView(message: messPack.message)
}
}.listRowInsets(EdgeInsets())
}
}
}
}
I'll be grateful for any help :)