0

I was wondering if there is a way to capture an UIImage as it appears as-is viewed in an UIImageView based on its contentMode. For example, if I pass a 3:4 aspect ratio to a square UIImageView, and use "Aspect Fit" as the contentMode, then I'd expect to see white letterboxes in the left and right parts the image to fill out the square. Would it then be possible to take whatever appears and save it directly as an new UIImage with the letter boxing?

Thanks!

daspianist
  • 5,336
  • 8
  • 50
  • 94
  • 1
    Try here, passing the imageview as the param: http://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display – danh May 03 '14 at 15:38

1 Answers1

2

You can capture a "screen shot" of the way a UIImageView is actually displayed by calling CALayer's renderInContext: method.

https://developer.apple.com/library/ios/documentation/graphicsimaging/reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instm/CALayer/renderInContext:

matt
  • 515,959
  • 87
  • 875
  • 1,141