开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜