Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johnmerlino

macrumors member
Original poster
Oct 22, 2011
81
0
Hey all,

When my table view loads, on the viewDidLoad I add this line of code:

Code:
              self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"unit_list_bg.png"]];

That line of code correctly displays the image on the table view but it also tiles the image on each of the cells, which is not what I want, as shown on the image attached to this post.

I just want the background image to be the background of the table not each table cell.

Also note that I originally had the background image applied to the view but the problem with that is the blue navigation bar on top clipped part of the image:

Code:
            self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"unit_list_bg.png"]];
            self.tableView.backgroundColor = [UIColor clearColor];

thanks for response
 

Attachments

  • tiling-issue.jpg
    tiling-issue.jpg
    41.7 KB · Views: 108
You are using a UIColor attribute for images. I know that it's possible.. but just, why? :p
I think you don't really understand the layers yet in an iOS frontend.
And to get a background on the tableview, just set it on the view behind the tableview, and make the tableview.backgroundcolor -> UIColor clearColor.
Since we don't even know what you are exactly trying to achieve, I cant give tips actually >;<
 
You are using a UIColor attribute for images. I know that it's possible.. but just, why? :p
I think you don't really understand the layers yet in an iOS frontend.
And to get a background on the tableview, just set it on the view behind the tableview, and make the tableview.backgroundcolor -> UIColor clearColor.
Since we don't even know what you are exactly trying to achieve, I cant give tips actually >;<

On the original question, I mentioned I tried that. But the blue navigation bar on the top eclipses it.

I kind of resolved this like this:

self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[[ UIImage imageNamed:mad:"bg.png"] stretchableImageWithLeftCapWidth:20 topCapHeight:0]];
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.