(UIImage *)transformToImage
{
CGSize selfSize = self.frame.size;
if ([self isKindOfClass:[UIScrollView class]]) {
UIScrollView scrollView = (UIScrollView )self;
selfSize = scrollView.contentSize;
}if (selfSize.width == 0 || selfSize.height == 0) {
return nil;
}UIGraphicsBeginImageContextWithOptions(selfSize, NO, [UIScreen mainScreen].scale);
CGContextRef context = UIGraphicsGetCurrentContext();if ([self isKindOfClass:[UIScrollView class]]) {
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, selfSize.width, selfSize.height)];
[self.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[contentView addSubview:obj];
}];
[contentView.layer renderInContext:context];
[contentView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[self addSubview:obj];
}];
} else {
[self.layer renderInContext:context];
}UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();return resultImage;
}
//解决两张图片合并模糊问题,放大倍数
UIImage * image1 = qrImageView.image;
UIImage * image2 = [UIImage imageNamed:@”Artboard.png”];
CGSize size = CGSizeMake(qrImageView.frame.size.width *3, qrImageView.frame.size.height *3);
UIGraphicsBeginImageContext(size);
[image1 drawInRect:CGRectMake(0, 0, size.width, size.height)];
[image2 drawInRect:CGRectMake(30 * 3, 30 * 3, size.width - 60 * 3, size.height - 60 * 3)];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
qrImageView.image = resultingImage;
UIGraphicsEndImageContext();