Travis Tubbs
Travis Tubbs

Reputation: 877

How do i make this background image static behind the collection view

here is my code, I have basically worked most of my problem out, however the background of my collection view is scrolling in a pattern behind my collection view... All of this scene is made programattically... I am wanting to make the background image that I have, but I want the colleciton view to scroll over it. But currently the background is scrolling with the text.

   // NSString *userId = PFUser currentId;
    PFQuery *query1 = [PFQuery queryWithClassName:PF_USER_CLASS_NAME];
    [query1 whereKey:PF_USER_OBJECTID equalTo:[PFUser currentId]];
    [query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
     {
         NSLog(@"madeIt");
         PFUser *user = [objects firstObject];
         UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:user[PF_USER_BACKGROUND]]]];
                 self.collectionView.backgroundColor = [UIColor colorWithPatternImage:image];
         //NSLog(user[PF_USER_BACKGROUND]);

     }];

Upvotes: 1

Views: 126

Answers (1)

Aneeq Anwar
Aneeq Anwar

Reputation: 1332

Set this as UIViewController's background color:

self.view.backgroundColor = [UIColor colorWithPatternImage:image];

And set UICollectionView's background colour as clear colour:

self.collectionView.backgroundColor = [UIColor clearColor];

Also, set UICollectionViewCell's background colour as clear colour, if required:

cell.backgroundColor = [UIColor clearColor];

Upvotes: 1

Related Questions