I have set the background colour of my UITableView to clear so that I can see the UIWindow. But I want to change the image presented (from background.png), depending on my selection. An example would be: If (selection = 'blue') then image = bluesky.png if (selection = 'green') then image = 'greengrass.png
thx, wes
您可以使用图像设置表格视图的背景颜色,而不是使背景清晰并在其后放置图像。
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"greengrass.png"]];
Just change the background image based on the selection, assuming your controller is UITableViewController
or implements the UITableViewDelegate
protocol, do something like:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *imageName = @"default.png";
switch (indexPath.row) {
case ...: // fill correct imageName based on selection
}
self.myBackgroundImageView.image = [UIImage imageNamed:imageName];
}
Btw - this also assumes you have an IBOutlet or something for your background image.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.