Quattz2D 截图保存到手机相册

来源:互联网 发布:ubuntu root权限 编辑:程序博客网 时间:2024/04/20 12:01

       


@interface JMViewController ()@property (strong, nonatomic) IBOutlet UIView *imageview;- (IBAction)click:(UIButton *)sender;@end@implementation JMViewController- (IBAction)click:(UIButton *)sender{    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{            //1新建 bitmap        UIGraphicsBeginImageContext(self.imageview.frame.size);            //2把图片画入到bitmap中              //2.1把当前view的layer画入上下文      [self.imageview.layer renderInContext:UIGraphicsGetCurrentContext()];            //3 取出图片    UIImage *imange = UIGraphicsGetImageFromCurrentImageContext();            //4 保存到相册    UIImageWriteToSavedPhotosAlbum(imange, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);    });                   }


0 0
原创粉丝点击