I am new to iOS development and I was wondering how do I add a background image that will repeat vertically to my UI Collection View that I have created to display an array of images?
For swift, add to viewDidLoad():
self.collectionView?.backgroundColor = UIColor(patternImage: UIImage(named: "background")!)
This will work as well and I think is more correct than the work around with the background color. Go for the backgroundView directly.
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImage.png"]];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imageName.pnd"]];
}
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