Do anyone have idea to add the background image to the collectionview directly in storyboard and is it possible to do so?
Better to do it programmatically creating a imageView like this
let imageView : UIImageView = {
let iv = UIImageView()
iv.image = UIImage(named:"imagename")
iv.contentMode = .scaleAspectFill
return iv
}()
and on the ViewDidLoad method
self.collectionView?.backgroundView = imageView
That'll make the background the image that you want
Yes it is possible I am using xcode 8.1 and it is possible in this version of xcode, I am not sure of other. for XCode 8.1 i have tried and working as expected.
you just have to drag UIImageView on UICollectionView and its done. Even it will automatically resize your UIImageView according to the size of your UICollectionView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With