zoukankan      html  css  js  c++  java
  • 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(@"截屏以保存至系统相册");
    }
  • 相关阅读:
    P1006 传纸条
    P1387 最大正方形
    P1417 烹调方案
    P1052 过河
    P1063 能量项链
    P1736 创意吃鱼法
    P1156 垃圾陷阱
    P1220 关路灯
    @P1373 小a和uim之大逃离
    【leetcode】Interleaving String
  • 原文地址:https://www.cnblogs.com/Ewenblog/p/10783702.html
Copyright © 2011-2022 走看看