iOS开发UITableViewCell的背景、文字、样式

1.系统默认的颜色设置

//无色 

cell.selectionStyle = UITableViewCellSelectionStyleNone;  

//蓝色  

cell.selectionStyle = UITableViewCellSelectionStyleBlue;  

//灰色  

cell.selectionStyle = UITableViewCellSelectionStyleGray; 

2.自定义颜色和背景设置

改变UITableViewCell选中时背景色

  1. UIColor *color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通过RGB来定义自己的颜色 
  2. cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];  
  3. cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];

3.自定义UITableViewCell选中时背景

  1. cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];  
  2. 还有字体颜色  
  3. cell.textLabel.highlightedTextColor = [UIColor xxxcolor]; [cell.textLabel setTextColor:color] 

4.设置tableViewCell间的分割线的颜色

[theTableView setSeparatorColor:[UIColor xxxx ]];

 

 

kADWColor(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

 

cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:ID].autorelease;

        cell.textLabel.backgroundColor = [UIColorclearColor];

        cell.detailTextLabel.backgroundColor = [UIColorclearColor];

        cell.detailTextLabel.font = [UIFontsystemFontOfSize:14];

        cell.backgroundColor = [UIColorclearColor];

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        //无色 

      cell.selectionStyle = UITableViewCellSelectionStyleNone;

 

// cell的背景颜色

    UIView *bg = [[UIViewalloc] init].autorelease;

    if (indexPath.row % 2 == 0) {

        bg.backgroundColor = kADWColor(50, 52, 37, 0.3);

  bg.backgroundColo = [UIColor colorWithRed:50 green:52 blue:37 alpha:0]

    }else{

        bg.backgroundColor = kADWColor(132, 66, 151, 1);

    }

 

 

posted @ 2014-03-25 17:19  光光96  阅读(264)  评论(0)    收藏  举报