Retain the size of a cell.imageView irrespective of the image size
I have a UITableViewCell
which contains a UIImageView
that resizes itself depending on the size of its image. Please could you tell me how I could retain the size of the UIIma开发者_运维百科geView
irrespective of the size of the image.
Generally speaking, a UIImageView
doesn't resize in response to the size of the image. What does happen, is that the UIImageView
will not clip the contents, so that you see the image exceeding the UIImageView
bounding frame.
You could make the UIImageView
resize the image to fit into the box, by doing
imageview.contentMode = UIViewContentModeScaleAspectFit;
or to fill the box:
imageview.contentMode = UIViewContentModeScaleAspectFill;
or you could let it crop the image:
imageview.clipsToBounds = YES;
精彩评论