如何将图像大于 uitableviewcell 本身作为子视图或背景视图。
我需要在选择单元格时显示背景图像。
编辑:附加文件见突出显示的行:箭头比tableview本身大,它比单元格大

如何将图像大于 uitableviewcell 本身作为子视图或背景视图。
我需要在选择单元格时显示背景图像。
编辑:附加文件见突出显示的行:箭头比tableview本身大,它比单元格大

In tableView datasource method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
you can do this :
UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_background.png"]];
cell.selectedBackgroundView = imageView;
When cell is selected its background is set to imageView.
如果您没有使用任何背景图像,则UITableViewCell使用此delegate method ofUITableView:`
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor redColor];
}
如果您使用的是背景图片,UITableViewCell则在cellForRowAtIndexPath:
UIImageView *selBGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage.png"]];
cell.selectedBackgroundView = selBGView;