我有一个UITableViewCell的子类。我正在尝试调整whiteLine
子视图的阿尔法,但该阿尔法仅在滚动到屏幕外单元格后才生效。最初一批whiteLine
子视图显示alpha为1.0。设置IUTableViewCell子类子视图的alpha
下面是我如何设置表格单元格:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CartCell";
BaseCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[BaseCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
[cell rowIsOdd:(indexPath.row%2 ? NO : YES)];
return cell;
}
这里就是我如何建立whiteLine
和表格单元格子内改变其阿尔法:
- (void)drawRect:(CGRect)rect
{
self.whiteLine = [[UIView alloc] initWithFrame:CGRectMake(0.0, self.frame.size.height-1.0, self.frame.size.width, 1.0)];
self.whiteLine.backgroundColor = [UIColor whiteColor];
[self addSubview:self.whiteLine];
}
- (void)rowIsOdd:(BOOL)isOdd
{
self.whiteLine.alpha = (isOdd ? 0.7 : 0.3);
}
可能的问题是我正在使用属性?我永远不知道何时不是使用属性。这绝对不是可以在此课程之外访问的属性。