是否可以将 [[cell imageView]
的宽度限制为标准的 UITableViewCell
?
我试过 [[cell imageView] setFrame:CGRectMake(0, 0, 50, 50)]
但它没有效果。
[编辑]
否则,是否可以在将 UIImage
添加到 UIImageView
之前更改它的大小?
最佳答案
您可以在 UIView 示例中使用 .transform 方法
cell.imageView.transform = CGAffineTransformMakeScale(0.65, 0.65);
//如果你是 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
}
}
关于iphone - 指定单元格 imageView 的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7202183/