gpt4 book ai didi

objective-c - 使用 UIButton 截取 UIView 的屏幕截图

转载 作者:可可西里 更新时间:2023-11-01 05:24:29 24 4
gpt4 key购买 nike

我正在尝试制作一个带有按钮的应用程序,该按钮将截取设备屏幕上绘制的对象的屏幕截图并将其保存在设备的照片库中...

我将如何做到这一点?有什么想法吗?

最佳答案

    UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShotimage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenShotimage, nil, nil, nil);
UIGraphicsEndImageContext();

此代码将截取您的屏幕截图并将图像保存在照片库中

关于objective-c - 使用 UIButton 截取 UIView 的屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8412077/

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