0
我有問題將頂部邊框設置爲UITableViewCell
。我的要求是爲所有單元格設置底部邊框,並僅爲第一個單元格設置頂部邊框。我用下面的代碼來設置此問題在UITableViewCell中設置邊框並在滾動時閃爍
if (indexPath.row == 0){
CALayer* topCellBorder = [CALayer layer];
topCellBorder.frame = CGRectMake(0, 1, CGRectGetWidth(cell.frame) , 0.5);
topCellBorder.backgroundColor = [config getColour:@"theme.table-border.color"].CGColor;
[cell.layer addSublayer:topCellBorder];
}
CALayer* bottomCellBorder = [CALayer layer];
bottomCellBorder.frame = CGRectMake(0, CGRectGetHeight(cell.frame) - 0.5, CGRectGetWidth(cell.frame) , 0.5);
bottomCellBorder.backgroundColor = [config getColour:@"theme.table-border.color"].CGColor;
[cell.layer addSublayer:bottomCellBorder];
但滾動後,頂部邊框消失了,加入到這樣
下一個視圖此外,我看到邊界閃爍時滾動。任何想法是什麼造成這種行爲
謝謝@Stefan。是的,我認爲細胞再利用是問題。但'awakeFromNib'是個好主意。將嘗試看到 – RameshVel
perfecto,它的工作 – RameshVel