我想创建一个半透明分组表视图单元格。换句话说,我想看到分组的表格视图背景图案,但我不想要完全清晰的单元格。我见过很多关于透明单元的问题,但没有一个解决制作半透明(仅部分透明)单元的问题。
这就是我正在尝试的:
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.contentView.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.5f];
cell.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];
}
And this is the result:
它几乎是正确的,除了单元格的 contentView 延伸到分组单元格的圆角之外。
SOLVED通过使用透明图像并设置单元格的背景视图。但仍然希望以编程方式完成,所以如果有人有解决方案,我会很乐意接受。
已解决第二部分还可以通过将backgroundView 设置为新的UIView 来完成,该UIView 通过QuartzCore 的setCornerRadius 调用视图的layer 属性具有所需的背景颜色和圆角。
这应该就是您所需要的:
cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.5];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)