iOS保存UIView到相册

    UIView *backView = (UIView *)[self.view viewWithTag:1001];

    CGSize s = backView.bounds.size;

    s = CGSizeMake(SCREEN_WIDTH - 80, 364);

    // 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三个参数就是屏幕密度了

    UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);

    [bacImageView.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

猜你喜欢

转载自www.cnblogs.com/lys-iOS-study/p/10302888.html