Create a scrolling background pattern for UITableView
If you want the background pattern image to scroll with a UITableView, you can set the backgroundColor.
UIImage *image = [UIImage imageNamed:@"pattern.png"];
UIColor *bgPattern = [UIColor colorWithPatternImage:image];
[tableView setBackgroundColor:bgPattern];
Now that the background is set, you'll notice that any UITableViewCells that are added to the table will contain their own copy of the pattern. To remove the cell's autoformatting you'll need to catch the cell after it has been created with the following delegate method.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[cell setBackgroundColor:[UIColor clearColor]];
}
Written by Christopher Matsumoto
Related protips
1 Response
you saved me! thanks a lot!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Xcode
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#