iOS 保存截图到相册(高清)

释放双眼,带上耳机,听听看~!
- (void)loadImageFinished:(UIImage *)image
{
    UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), (__bridge void *)self);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{

    NSLog(@"image = %@, error = %@, contextInfo = %@", image, error, contextInfo);
}


    //截图功能
-(UIImage *)captureImageFromView:(UIView *)view
{

    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];

    CGRect rect = [keyWindow bounds];

    UIGraphicsBeginImageContextWithOptions(rect.size,YES, 0.0);

    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return snapshotImage;
}

- (IBAction)savePhotoButton:(UIButton *)sender {

    [self loadImageFinished:[self captureImageFromView:self.view]];
    kShowD(@"截屏以保存至系统相册");
}

 

人已赞赏
iOS文章

iOS子线程更新UI到主线程的三种方法

2019-12-2 21:31:41

iOS文章

iOS电池条颜色设置成白色

2019-12-3 10:33:50

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索