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

标签 objective-c ios ipad

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

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

最佳答案

    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/

相关文章:

html - 如何在swift 4中的webview中显示大量数据

linux - 如何访问打开的终端 session

objective-c - 由于保留或其他原因导致的泄漏? ( Objective-C )

objective-c - 如何在 Kiwi 中对模拟方法的参数设置期望

iphone - 添加 CAGradientLayer 子层时,UITableViewCell 不会拾取 UITableViewCellSelectionStyleBlue

ios - 在 iOS 7 中自定义 UISearchBar

ios - 其他链接器标志设置为 -ObjC

ios - 如何获取 tableView 和 tabBar 之间的大小?

iOS 10 : UIAlertController only showing one action

iphone - 插入 View Controller 时应用程序崩溃