ios – UITableViewCell imageView填充

前端之家收集整理的这篇文章主要介绍了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”

原文链接:https://www.f2er.com/iOS/335376.html

猜你在找的iOS相关文章