iphone - 指定单元格 imageView 的宽度

标签 iphone ios uitableview uiimageview

是否可以将 [[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/

相关文章:

iphone - UIController 的选择性自动旋转

ios - 如何添加 didSet 以查看 UIViewController 的属性?

ios - UITableView cellForRowAtIndexPath 没有被调用

ios - 以编程方式在 tableView 和 BottomLayoutGuide 之间添加 View

ios - UITableViewCell 在 iOS 11 中的行为不同

ios - 如何使用FBSDKLoginManager进行FB登录?

iPhone: "initWithNibName:bundle:"的 TableViewController nibName 错误

iphone - 初始化后如何将 NSManagedObject 关联到上下文?

android - 向 ios 和 android 设备发送 Firebase 云消息

ios - 在 xCode 中导入用 <> 符号包围的 .h 文件?