sim*_*nbs 14 iphone sdk uitableview accessoryview
我试图设置我的UITableViewCells的单元格背景,但我正在努力与UIAccessoryView的背景颜色.它没有改变.
任何人都可以帮助我使UIAccessoryView的背景颜色透明(或实际上任何其他颜色)?
这是我的代码
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.accessoryView.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if(indexPath.row % 2) {
cell.contentView.backgroundColor = [UIColor clearColor];
}
else {
cell.contentView.backgroundColor = [UIColor redColor];
}
Run Code Online (Sandbox Code Playgroud)
这是一个说明问题的图像

Dar*_*ren 46
您需要设置backgroundViewUITableViewCell 的属性.例如:
UIView* myBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
myBackgroundView.backgroundColor = [UIColor redColor];
myCell.backgroundView = myBackgroundView;
Run Code Online (Sandbox Code Playgroud)
如果你想要更加花哨的东西,比如红色渐变背景,你可以实现绘制渐变的UIView的子类drawRect:,并将其用作backgroundView.
selectedBackgroundView如果要自定义查找选定的表格单元格,也可以设置该属性.
功能中
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
使用以下代码
cell.contentView.superview.backgroundColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5762 次 |
| 最近记录: |