能否根据UIimageView的内容模式捕获UIImage?

我想知道是否有一种捕获UIImage的方法,因为它看起来像是在基于其contentModeUIImageView查看的。 例如,如果我将3:4宽高比传递给方形UIImageView ,并使用“Aspect Fit”作为contentMode ,那么我希望在图像的左侧和右侧部分看到白色信箱以填充方形。 那么它是否有可能采取任何出现并直接保存为一个新的UIImage与字母拳击?

谢谢!

您可以通过调用CALayer的renderInContext:方法捕获实际显示UIImageView的方式的“屏幕截图”。

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