Resize UIImageView in UITableViewCell

后端 未结 4 1218
暖寄归人
暖寄归人 2020-12-16 03:51

I have a 16x16 pixel image that I want to display in an UIImageView. So far, no problem, however 16x16 is a bit small so I want to resize the image view to 32x32 and thus al

4条回答
  •  情歌与酒
    2020-12-16 04:04

    You need to override the layoutSubviews method. By default, it's resizing the imageview based on the cell height size.

    -(void)layoutSubviews
    {
        [super layoutSubviews];
    
        self.imageView.frame = CGRectMake(self.imageView.frame.origin.x,
                                          self.imageView.frame.origin.y,
                                          MY_ICON_SIZE,
                                          MY_ICON_SIZE);
    }
    

    You'll probably want to recalculate the origin as well so it's vertically centered.

提交回复
热议问题