I'm programatically trying to add a label to the collection view when the collection view is empty so let the user know that the collection view is empty. I created a function to do this. However, whenever the collection view isn't empty anymore, I can't get the label to disappear, does anyone know how I can change this. Here is my code:
func EmptyCollectionView() {
if communities.count == 0 {
let messageLabel = UILabel(frame: CGRect(x: 20.0, y: 0, width: self.collectionViews!.bounds.size.width - 40.0, height: (self.collectionViews?.bounds.size.height)!))
messageLabel.text = "You haven't created anything yet!"
messageLabel.font = messageLabel.font.withSize(20)
messageLabel.font = UIFont.boldSystemFont(ofSize: messageLabel.font.pointSize)
messageLabel.textColor = colorCircleBlue
messageLabel.numberOfLines = 0
messageLabel.textAlignment = NSTextAlignment.center
messageLabel.sizeToFit()
self.collectionViews?.backgroundView = messageLabel
} else {
addPhoto()
}
}