Created
March 4, 2016 02:36
-
-
Save kineticac/5416cb64ed9b8d9a0b08 to your computer and use it in GitHub Desktop.
UIImageView's image does not respect ScaleAspectFit contentMode unless the image originated as a CGImage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume these return images from disk purely as CI and CG images | |
let ciImage = createPureCIImage() | |
let cgImage = createPureCGImage() | |
// This fetches the imageView reference | |
let imageView = getUIImageView() | |
imageView.contentMode = .ScaleAspectFit | |
// this will not show aspect fit | |
imageView.image = UIImage(CIImage: ciImage) | |
// this WILL show aspect fit | |
imageView.image = UIImage(CGImage: cgImage) | |
// this will also show it, assume convertCIImagetoCGImage does just that | |
imageView.image = UIImage(CGImage: convertCIImagetoCGImage(ciImage)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment