我希望为UITableView单元格的imageView设置边距或填充,我该怎么做?
通过
以下是我的cellForRow方法:
heightForRowAtIndexPath
方法,我只能设置行高。如果增加行高,它只会放大单元格中的图像。以下是我的cellForRow方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
cell.textLabel.numberOfLines = 1;
cell.textLabel.font = [UIFont systemFontOfSize:kSystemFontSize];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.textColor = [UIColor whiteColor];
}
cell.textLabel.text = [_dataArray objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[_imageArray objectAtIndex:indexPath.row]];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
目前我只知道一种方法可以做到这一点——使用Photoshop或类似的程序缩小图片内容,同时保持原来的大小。但这样的方法需要花费很多时间,我想应该有更简单的方法。
CGAffineTransformMakeScale(0.5, 0.5)
。 - Pang