gpt4 book ai didi

iphone - 为 UIImageView 截屏

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:09:20 27 4
gpt4 key购买 nike

我想截取我 View 中特定部分的屏幕截图(具体来说是 ImageView ),是否有机会....

最佳答案

看来您需要执行 renderInContext

// Size of the result rendered image
CGSize targetImageSize = CGSizeMake(100, 100);
// Check for retina image rendering option
if (NULL != UIGraphicsBeginImageContextWithOptions) UIGraphicsBeginImageContextWithOptions(targetImageSize, NO, 0);
else UIGraphicsBeginImageContext(targetImageSize);

CGContextRef context = UIGraphicsGetCurrentContext();
// The view to be rendered
[[yourImageView layer] renderInContext:context];
// Get the rendered image
UIImage *original_image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

关于iphone - 为 UIImageView 截屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7159444/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com