Open chrisballinger opened 7 years ago
/// Sets the constraints of the `MessagesCollectionView`.
private func setupConstraints() {
messagesCollectionView.translatesAutoresizingMaskIntoConstraints = false
let top = messagesCollectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: topLayoutGuide.length)
let bottom = messagesCollectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
if #available(iOS 11.0, *) {
let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor)
let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
NSLayoutConstraint.activate([top, bottom, trailing, leading])
} else {
let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor)
let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
NSLayoutConstraint.activate([top, bottom, trailing, leading])
}
}
The previous solution doesn't seem to work with Objective-C.
I've found a different workaround, here are the steps:
For an example, see the below picture where the messageInputBar overlaps the new "home button bar" area.