ios – UITableViewCell imageView填充

我想为UITableView单元格imageView设置边距或填充,我该怎么办?
使用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或类似的程序缩小图像的图像内容,同时保持.但是这种方法需要花费很多时间,我想应该有更简单的方法来做到这一点.

解决方法

没有子类:
cell.imageView.transform = CGAffineTransformScale(CGAffineTransformIdentity,.5,.5);

根据您的情况以适当的比例更改“.5”

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...