我有一个 UITableView,其中有 3 个图像。 1 表示选定的 Cell,1 表示 Cell 背景,1 表示 TableView 背景。
我选择的单元格工作正常,但正常单元格和 TableView 背景(当您向下/向上滚动太多时单元格后面的背景)存在一些问题
有人可以帮我设置每个单元格的背景和 TableView 背景吗?这是怎么做到的?
正常细胞背景:(不确定是否正确)
// CELL'S BACKGROUND-IMAGE
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]];
选定的单元格背景:
// SELECTED CELL'S BACKGROUND-IMAGE
UIView *viewSelected = [[[UIView alloc] init] autorelease];
viewSelected.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"cell_highlighted.PNG"]];
cell.selectedBackgroundView = viewSelected;
最佳答案
对于单元格
cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cell_normal.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"cell_pressed.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
对于表格 View
[mEditTableView setBackgroundView:nil];
[mEditTableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"apple.png"]] ];
关于iphone - 带有背景图像的 UITableView 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6329832/