- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCell];
if (indexPath.row == 0) {
cell.textLabel.text = @"新浪微博"; //cell的text內(nèi)容
UIView *lbl = [[UIView alloc] init]; //定義一個(gè)label用于顯示cell之間的分割線(未使用系統(tǒng)自帶的分割線)怔檩,也可以用view來(lái)畫(huà)分割線
lbl.frame = CGRectMake(cell.frame.origin.x + 10, cell.frame.size.height - 5, cell.frame.size.width - 20, 1);
lbl.backgroundColor = [UIColor lightGrayColor];
[cell.contentView addSubview:lbl];
}
UILabel *label = [[UILabel alloc] init]; //定義一個(gè)在cell最右邊顯示的label
label.text = @"Dark0921";
label.font = [UIFont boldSystemFontOfSize:14];
[label sizeToFit];
label.backgroundColor = [UIColor clearColor];
label.frame =CGRectMake(375 -label.frame.size.width - 10, 12, label.frame.size.width, label.frame.size.height);
[cell.contentView addSubview:label];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor grayColor];
return cell;
} else{
UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:kTableViewCell1];
cell1.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //顯示最右邊的箭頭
cell1.textLabel.text = @"添加好友";
return cell1;
}
}
實(shí)現(xiàn)后的效果:
屏幕快照 2015-12-22 下午2.12.26.png