IOS TableView代理设置 table的行高

 

 

    // 设置行高(每一行的高度一致)
      self.tableView.rowHeight = 60;
    
      self.tableView.delegate = self;






#pragma mark - 代理方法
/**
 *  每一行的高度不一致的时候使用这个方法来设置行高
 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) return 100;
    return 60;
}

 

    //设置cell右边指示器的类型
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    
    
    //设置背景(view不用设置尺寸,backgroundView的优先级>barckgroundColor)
    UIImageView *bgView=[[UIImageView alloc]init];
    bgView.image=[UIImage imageNamed:@"buttondelete"];
    cell.backgroundView=bgView;
    
    
    UIView *selectedbgView = [[UIView alloc] init];
    selectedbgView.backgroundColor = [UIColor greenColor];
    cell.selectedBackgroundView = selectedbgView;

 

posted on 2017-02-23 11:40  守望星空  阅读(844)  评论(0编辑  收藏  举报

导航