创建一个UIimageView,把需要合成的图片文字添加到imageView中 使用方法
下载到本地
self.imageView.image = [self imageWithView:self.imgageView];//多图合成
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
//写入图片到相册
PHAssetChangeRequest *req = [PHAssetChangeRequest creationRequestForAssetFromImage:self.fisrtImgView.image];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
NSLog(@"success = %d, error = %@", success, error);
}];
- (UIImage *)imageWithView:(UIImageView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, [[UIScreen mainScreen] scale]);//图形以选项开始图像上下文
[view.layer renderInContext:UIGraphicsGetCurrentContext()];/**渲染属性和方法。* * /
/*将接收器及其子处理器呈现为“ctx”。这个方法
*从图层树直接渲染。在坐标空间中呈现的层。
*/
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();//*图像从当前图像上下文获取图像
UIGraphicsEndImageContext();//结束图像上下文
return img;
}