• 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(@"截屏以保存至系统相册");
    }
  • 相关阅读:
    UVa 541 Error Correction
    UVa 11045 My T-shirt suits me
    【模板】Ford-Fulkerson算法
    POJ 1273 Drainage Ditches
    UVa 10158 War
    UVa 658 It's not a Bug, it's a Feature!
    【模板】并查集
    【模板】Floyd-Warshall算法
    UVa 10034 Freckles
    UVa 10048 Audiophobia
  • 原文地址:https://www.cnblogs.com/Ewenblog/p/10783702.html
Copyright © 2020-2023  润新知