在我的项目中,我有带有静态单元格的 tableViews 以及带有动态单元格的 tableViews。为了定制,我设法在单元格上获得了渐变背景(分组样式)。
它适用于动态 TableViews,因为我根据行的位置(顶部、底部、中间或单个)在 cellForRowAtIndex... 中设置背景视图。
但是,当我尝试在静态 tableview 单元格上实现它时,它不起作用。我试图实现 cellForRowAtindex... 但它崩溃了。
有人有想法吗?
更新:cellForRow 的代码..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UACellBackgroundView *bgw=[[UACellBackgroundView alloc]init];
if (indexPath.row==0) {
bgw.position = UACellBackgroundViewPositionTop;
cell.backgroundView=bgw;
}else if (indexPath.row==2){
bgw.position = UACellBackgroundViewPositionBottom;
cell.backgroundView=bgw;
}else {
bgw.position = UACellBackgroundViewPositionMiddle;
cell.backgroundView=bgw;
}
// cell.backgroundView=bgw;
return cell;
}
顺便说一句,我从这里得到的背景视图: http: //code.coneybeare.net/how-to-make-custom-drawn-gradient-backgrounds 和这里: http: //pessoal.org/blog/2009 /02/25/customizing-the-background-border-colors-of-uitableview/
如果有人感兴趣