如何将图像大于uitableviewcell本身作为子视图或背景视图。
我需要显示选择单元格时的背景图像。
修改: 文件附件见突出显示的行:箭头大于tableview本身,它大于单元格
答案 0 :(得分:0)
在tableView数据源方法
中- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
你可以这样做:
UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_background.png"]];
cell.selectedBackgroundView = imageView;
选择单元格后,其背景设置为imageView
。
答案 1 :(得分:0)
如果您没有使用UITableViewCell
的任何背景图片,请使用此delegate method of
UITableView:`
- (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;