美文网首页
保存页面的方法

保存页面的方法

作者: 这个姑凉儿 | 来源:发表于2022-06-15 15:30 被阅读0次

        UIGraphicsBeginImageContextWithOptions(bgView1.bounds.size, YES, 0.0);
        [bgView1.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        [self saveImageToPhotos:img];



- (void)saveImageToPhotos:(UIImage*)savedImage
{
    UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
    //因为需要知道该操作的完成情况,即保存成功与否,所以此处需要一个回调方法image:didFinishSavingWithError:contextInfo:
}
//回调方法
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
    NSString *msg = nil ;
    if(error != NULL){
        msg = @"保存图片失败" ;
    }else{
        msg = @"保存图片成功" ;
    }

}

相关文章

网友评论

      本文标题:保存页面的方法

      本文链接:https://www.haomeiwen.com/subject/aoavmrtx.html