user337174
user337174

Reputation: 71

Is there a way to fix the background image of a UITableView

I have set the background of my UITable with a custom image.

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

The problem I'm having is the background image is scrolling and doesn't look good at the top and bottom of the screen where you see the image being joined.

Is there a way to fix the position of the background image and just have the table scroll over the top of it?

Upvotes: 2

Views: 460

Answers (2)

Dan Ray
Dan Ray

Reputation: 21893

You need to put a UIImageView beneath your table view, set the table view's background color to clear (or in IB, set the opacity property of its background at 0). Then construct your CELL views to have clear areas that your background image can be seen through. You can do that programmatically or in IB (it's easier to visualize in IB, but the code to hook it all together is a bit tricky).

Upvotes: 0

Alastair Stuart
Alastair Stuart

Reputation: 4185

Insert a UIImageView behind the UITableView. Set the UIImageView's image to background.png. Use [UIColor clearColor] as the table's background.

Upvotes: 1

Related Questions