【问题标题】:Able to capture UIImage as-is based on content mode from UIimageView?能否根据 UIimageView 的内容模式按原样捕获 UIImage?
【发布时间】:2014-06-20 05:07:14
【问题描述】:

我想知道是否有一种方法可以捕获UIImage,因为它在基于contentModeUIImageView 中显示为原样。例如,如果我将3:4 纵横比传递给正方形UIImageView,并使用“Aspect Fit”作为contentMode,那么我希望在图像的左右部分看到白色信箱来填充出广场。那么是否可以将出现的任何内容直接保存为带有信箱的新UIImage

谢谢!

【问题讨论】:

标签: ios iphone uiimageview uiimage crop


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    相关资源
    最近更新 更多