I'm trying to scale down UIImage to fit the exact same size my UIView has, Tho i'm not sure what is the exact relations between them.
This is the way i'm checking if my UIImage bigger than my UIView.
let rect = preview.frame
if croppedImage.size.width * croppedImage.scale > rect.size.width * UIScreen.
UIImage class reference, referring to the
If you multiply the logical size of the image (stored in the
sizeproperty) by the value in this property, you get the dimensions of the image in pixels.
UIWindow class reference, referring to its own
This value reflects the scale factor needed to convert from the default logical coordinate space into the device coordinate space of this screen. The default logical coordinate space is measured using points. For standard-resolution displays, the scale factor is 1.0 and one point equals one pixel. For Retina displays, the scale factor is 2.0 and one point is represented by four pixels.
So you should be able to compare
croppedImage.size.width * croppedImage.scale with
rect.size.width * UIScreen.scale. However, you may want to consider placing your
UIImage into a
UIImageView. Then you can set the
frame property on the
UIImageView to your view's frame and voila! (Note, however, that this may stretch your image.)