I have the image view which has fixed size. But I want to fit every size of image into this without stretching.
I tried this
In method resizeImage, I passed my selected image and size of UIImageView.
func resizeImage(image: UIImage, size: CGSize) -> UIImage {
UIGraphicsBeginImageContext(size)
image.drawInRect(CGRectMake(0, 0, size.width, size.height))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}
But this is not working, It is still returning the stretched image.
Please let me know what could be the proper solution.
Thanks