指定单元格imageView的宽度

Nie*_*gen 2 iphone uitableview uiimageview ios

是否可以约束[[cell imageView]标准的宽度UITableViewCell?我试过[[cell imageView] setFrame:CGRectMake(0, 0, 50, 50)]但它没有效果.

[编辑]

否则,是否可以UIImage在添加之前更改大小UIImageView

Cha*_*ndo 6

您可以在UIView示例中使用.transform方法

cell.imageView.transform = CGAffineTransformMakeScale(0.65, 0.65);
Run Code Online (Sandbox Code Playgroud)

//如果你是UITableViewCell的子类,你也可以这样做

- (void)layoutSubviews {

    [super layoutSubviews];
    self.imageView.bounds = CGRectMake(10,5,65,65);
    self.imageView.frame = CGRectMake(10,5,65,65);
    self.imageView.contentMode = UIViewContentModeScaleAspectFit;

    if (self.imageView.image) {
        //TODO: adjust the textLabel and detailTextLabel
    }

}
Run Code Online (Sandbox Code Playgroud)