开发者

UIImage scale propotionally

开发者 https://www.devze.com 2023-03-30 02:53 出处:网络
I have a UIImageView. and i am setting a UIImage to this UIImageView with content mode as UIConte开发者_StackOverflowntModeScaleAspectFit. Can i know the scale in which the UIImage is resizing when us

I have a UIImageView. and i am setting a UIImage to this UIImageView with content mode as UIConte开发者_StackOverflowntModeScaleAspectFit. Can i know the scale in which the UIImage is resizing when using UIContentModeScaleAspectFit.


Yes, but not automatically :)

The scale will be something like

CGFloat widthScale = imageView.bounds.size.width / image.size.width;
CGFloat heightScale = imageView.bounds.size.height / image.size.height;

You will have to use the correct one depending on if the image has fitted vertically or horizontally ;)

0

精彩评论

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

关注公众号