我有一个UITableView
分组样式和UITableViewCell
,我需要更宽一些。所以,我将UITableViewCell
子类化并实现了一个方法:
- (void) layoutSubviews
{
[super layoutSubviews];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && !IS_OS_7_OR_LATER) {
CGRect frame = self.frame;
frame.origin.x -= 10;
frame.size.width += 20;
self.frame = frame;
}
}
现在有一个问题 - 我的手机看起来像这样:
并使用颜色图层:
在单元格的顶部,在调整大小之前,前一个单元格的边界有一部分..这可以在第二个屏幕上清楚地看到。你能帮我解决这个边界的问题吗?
答案 0 :(得分:0)
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.bounds];
backgroundView.backgroundColor = [UIColor colorWithRed:240 green:240 blue:240 alpha:1];
cell.backgroundView = backgroundView;
试一试。