我在这个表视图中的每个单元格的左上角绘制了这个奇怪的半圆。我似乎无法摆脱它。虽然单元格都是UITableViewCell的子类,但我没有在我的单元格中进行任何自定义绘图。
弯曲的工件仅出现在每个部分的第一个单元格中,并且无论表视图背景如何,它仍然是持久的。
这是单元格中的所有自定义代码,其余代码在IB
中- (void)layoutSubviews {
// NSLog(@"DataEntryCell layoutSubviews");
UILabel *topLabel = [self parameterLabel];
UILabel *bottomLabel = [self dataLabel];
topLabel.font = [UIFont boldSystemFontOfSize:18.0];
topLabel.textAlignment = UITextAlignmentCenter;
topLabel.textColor = [UIColor darkGrayColor];
topLabel.shadowColor = [UIColor lightGrayColor];
topLabel.shadowOffset = CGSizeMake(0.0, 1.0);
bottomLabel.font = [UIFont systemFontOfSize:16.0];
bottomLabel.textAlignment = UITextAlignmentLeft;
bottomLabel.textColor = [UIColor darkGrayColor];
bottomLabel.numberOfLines = 0;
bottomLabel.lineBreakMode = UILineBreakModeWordWrap;
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.selectionStyle = UITableViewCellSelectionStyleGray;
self.autoresizesSubviews = YES;
}
知道可能导致这种情况的原因吗?
由于
答案 0 :(得分:1)
我没有看到layoutSubviews
中真正属于那里的任何内容。创建标签时,应设置标签上的所有属性。同样关于自我的属性。特别是selectionStyle
似乎很可疑,因为它提到了灰色并且你有一个灰色的流线。在调用layoutSubviews
时,设置autoresizesSubviews
为时已晚;自动调整在您收到layoutSubviews
之前发生。
尝试将这些内容放在单元格初始化的附近 - 如果您正在从笔尖加载单元格(及其子视图),或者使用创建和添加子视图的代码,请放在awakeFromNib
中。