知道如何移动 UITableViewCell 文本,使其不与左侧的小图像重叠吗?
这是一个屏幕截图:
谢谢你的帮助
这是我的 TableCell 代码:
- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UILabel* nameLb;
UILabel* detailsLb;
UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:@"log-cell"];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"log-cell"] autorelease];
UIImage* img = [ImgUtil image:[NSString stringWithFormat:@"butList3_%d.png", [[SelectCategory instance] select] + 1 ]];
UIImageView* bgImage = [[[UIImageView alloc] initWithImage:img ]autorelease];
[cell addSubview:bgImage ];
[cell sendSubviewToBack:bgImage ];
nameLb = [[[UILabel alloc] initWithFrame:CGRectMake(5, 5, 250, 40)] autorelease];
[nameLb setNumberOfLines:4];
[nameLb setBackgroundColor:[UIColor clearColor]];
[nameLb setTextColor:[UIColor whiteColor]];
[nameLb setTag:NAME_TEXT];
[nameLb setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];
[nameLb setMinimumFontSize:10];
[cell addSubview:nameLb];
//add UIImage
cell.imageView.image = [UIImage imageNamed:@"shop.png"];
detailsLb = [[[UILabel alloc] initWithFrame:CGRectMake(5, 45, 250, 20)] autorelease];
[detailsLb setBackgroundColor:[UIColor clearColor]];
[detailsLb setTextColor:[UIColor whiteColor]];
[detailsLb setTag:DETAILS_TEXT];
[detailsLb setFont:[UIFont fontWithName:@"Helvetica" size:12]];
[cell addSubview:detailsLb];
}else {
nameLb = (UILabel*)[cell viewWithTag:NAME_TEXT];
detailsLb = (UILabel*)[cell viewWithTag:DETAILS_TEXT];
}
ObjectInfo* obj = [myList objectAtIndex:indexPath.row ] ;
nameLb.text = [obj name];
// cell.textLabel.textColor = [UIColor whiteColor];
// cell.textLabel.font = [UIFont boldSystemFontOfSize:17];
double distance = [ProjUtil getDistanceWithLat1:currentLocation.latitude long1:currentLocation.longitude lat2:obj.location.latitude long2:obj.location.longitude];
detailsLb.text = [NSString stringWithFormat:@"%.2f miles", [ProjUtil kmToMi:distance]];
// cell.detailTextLabel.textColor = [UIColor whiteColor];
// cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[cell setBackgroundColor:[UIColor clearColor]];
///[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;
}