How do I add a background image to a grouped style

2019-04-09 18:52发布

问题:

self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"fullscreen-bg.png"]];
self.tableView.backgroundColor = [UIColor clearColor];

That code worked fine in iOS 5 but it doesn't work in iOS 6. In iOS 6 it just show the default pinstriped background. Any ideas?

回答1:

You can add the image as a background view

[tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]]];

And That's it



回答2:

// FOR iOS 5
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;

// FOR iOS 6
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
self.tableView.backgroundView = nil;


标签: ios ios6