2013-03-06 65 views
1

請參閱以下附件圖像。我想從 UITableViewCell中刪除白色。如何從桌面單元中刪除白色。? enter image description here如何從UITable中刪除白色查看單元格

這裏是我的代碼:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 

     static NSString *CellIdentifier = @"Cell"; 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    cell=nil; 

     if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
     } 
     Schedule *sch=(Schedule*)[tableDataList objectAtIndex:indexPath.row]; 

     NSString*[email protected]""; 

     if(sch.ptime.length<8){ 
     ptime=[ptime stringByAppendingString:@" "]; 
     ptime=[ptime stringByAppendingString:sch.ptime]; 
    } 
    else 
    { 
    ptime=[ptime stringByAppendingString:sch.ptime]; 
    } 

    UILabel *lbPTime=[[UILabel alloc]initWithFrame:CGRectMake(5, 10, 80, 25)]; 
    lbPTime.font=[UIFont fontWithName:@"Zawgyi-One" size:15]; 
    lbPTime.textColor=[UIColor whiteColor]; 
    [lbPTime setText:ptime]; 

    NSString*[email protected]""; 
    pname=[pname stringByAppendingString:sch.pname]; 
    pname=[pname stringByAppendingString:@" "]; 

    UILabel *lbPName=[[UILabel alloc]initWithFrame:CGRectMake(lbPTime.frame.size.width, 10, 250, 25)]; 
    lbPName.font=[UIFont fontWithName:@"Zawgyi-One" size:15]; 

    CGSize maximumLabelSize=CGSizeMake(296, 9999); 
    CGSize expectedLabelSize= [pname sizeWithFont:lbPName.font 
              constrainedToSize:maximumLabelSize 
               lineBreakMode:lbPName.lineBreakMode]; 
    CGRect newFrame=lbPName.frame; 
    newFrame.size.height=expectedLabelSize.height; 
    newFrame.size.width=expectedLabelSize.width; 
    lbPName.frame=newFrame; 
    lbPName.numberOfLines=0; 
    lbPName.lineBreakMode=UILineBreakModeWordWrap; 
    lbPName.textColor=[UIColor whiteColor]; 
    [lbPName setText:pname]; 

    [cell.contentView addSubview:lbPTime]; 
    [cell.contentView addSubview:lbPName]; 
    [cell.contentView sizeToFit]; 

    UIView *v = [[UIView alloc]init]; 
    v.backgroundColor = self.tableview.backgroundColor;//[UIColor clearColor]; 

    cell.selectedBackgroundView = v; 
    cell.backgroundColor=[UIColor clearColor]; 
    return cell; 
} 
+0

你在談論的白線? – Rushi 2013-03-06 09:24:17

+1

@Rushi nope,白色塊 – 2013-03-06 09:27:17

回答

5

同時設置UILabel背景顏色爲clearColor

[lbPTime setBackgroundColor:[UIColor clearColor]]; 
[lbPName setBackgroundColor:[UIColor clearColor]]; 
0

除去白色邊框:

tableView.separatorColor = [UIColor clearColor]; 
3

使用此代碼刪除白色邊框。

tableView.separatorColor = [UIColor clearColor]; 

編輯:

,那白塊是因爲UILabel的你使用。將背景顏色更改爲clearColor

lbPTime.backgroundColor = [UIColor clearColor]; 
lbPName.backgroundColor = [UIColor clearColor]; 
+0

tableView.separatorColor = [UIColor clearColor];不需要添加。 – 2013-03-06 09:35:53

+1

@PhoenixKyaw:同意。起初我以爲你問的是細胞之間的白線。 – Rushi 2013-03-06 09:38:37

0

我認爲標籤的背景需要被

lbPName.backgroundColor=[UIColor clearColor]; 
0

那麼設定明確的顏色,它是爲textLabel的背景色(試試這個代碼):

cell.textLabel.backgroundColor = [UIColor clearColor]; 

有一個嘗試。

+0

好吧,它是lbPName的backgroundColor。 – junkor 2013-03-06 09:30:49

1

設定這個屬性也爲您的屬性

lbPTime.backgroundColor=[UIColor clearColor];