我有一個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);
}
可能的問題是我正在使用屬性?我永遠不知道何時不是使用屬性。這絕對不是可以在此課程之外訪問的屬性。