iOS 13 is out, and I can't figure out for the life of me how to change the CollectionView's background color to support dark mode.
Finally...
```swift
private func setupCollectionView() {
guard let flowLayout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout else {
print("Can't get flowLayout")
return
}
if #available(iOS 13.0, *) {
flowLayout.collectionView?.backgroundColor = .systemBackground
}
}
func inputStyle() {
if #available(iOS 13.0, *) {
messageInputBar.inputTextView.textColor = .label
messageInputBar.inputTextView.placeholderLabel.textColor = .secondaryLabel
messageInputBar.backgroundView.backgroundColor = .systemBackground
} else {
messageInputBar.inputTextView.textColor = .black
messageInputBar.inputTextView.backgroundColor = UIColor.rgb(red: 245, green: 245, blue: 245)
}
}
@nitrag could you please expaine where I should place this code?
@AlexeyShevchenko
internal class YourViewController: MessagesViewController
Don't forget to setup delegates
Most helpful comment
Finally...
```swift
private func setupCollectionView() {
guard let flowLayout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout else {
print("Can't get flowLayout")
return
}
if #available(iOS 13.0, *) {
flowLayout.collectionView?.backgroundColor = .systemBackground
}
}
func inputStyle() {
if #available(iOS 13.0, *) {
messageInputBar.inputTextView.textColor = .label
messageInputBar.inputTextView.placeholderLabel.textColor = .secondaryLabel
messageInputBar.backgroundView.backgroundColor = .systemBackground
} else {
messageInputBar.inputTextView.textColor = .black
messageInputBar.inputTextView.backgroundColor = UIColor.rgb(red: 245, green: 245, blue: 245)
}
}