2013-04-22 69 views
0

我在我的tableView中有四個部分,我只希望最後一部分有一個清晰的分隔符。我知道如何爲整個tableView做到這一點,但找不到我的問題的任何解決方案。我想到的唯一解決方案是在Photoshop中將圖像單元創建爲圖像,並將該圖像設置爲單元格背景。有沒有人有一個如何做到這一點,而不必使用Photoshop的想法?如何設置tableView的一個部分的分隔符清除

回答

0

試試這個

在查看didLoad

tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

而且

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if(cell==nil) 
    { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 1)]; 
     view.backgroundColor = [UIColor greenColor]; 
     view.tag = 101; 
     [cell addSubview:view]; 
    } 


    if (indexPath.section == 0) 
    { 
     [[cell viewWithTag:101] setHidden:YES]; 
    } 
    else if(indexPath.section == 1) 
    { 
     [[cell viewWithTag:101] setHidden:NO]; 
    } 
    return cell; 
} 
相關問題