It looks like aspect fit
aligns the image to the bottom of the frame by default. Is there a way to override the alignment while keeping aspect fit
intact?
** EDIT **
This question predates auto layout. In fact, auto layout was being revealed in WWDC 2012 the same week this question was asked
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
To maintain aspect ratio I calculated the width of UIImageView = (320/460)*450 = 313.043 dynamically. And set the contentMode For UIImageView is UIViewContentModeScaleAspectFit. And set the image(320x460) to image view but it is some what blur.
Make UIImageView Corners Rounded I will now use the created in the above Swift code snippet UIImageView and will make its corners rounded by changing the value of CALayer cornerRadius and setting the UIImageView clipsToBounds value to true. Setting the corner radius to 100 will make the image view completely rounded.
In short, you cannot do this with a UIImageView
.
One solution is to subclass a UIView
containing an UIImageView
and change its frame according to image size. For example, you can find one version here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With