如何将几张图像作为一个图像快速保存到照片库? [英] How to save a couple of images as one image to photo library in swift?

查看:90
本文介绍了如何将几张图像作为一个图像快速保存到照片库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一个视图控制器中有三个imageViews(两个甜甜圈png和一个Simpson图像).有什么解决方案可以将这些图像捕获为一张图像并将其保存到照片库中?谢谢.

There are three imageViews in first view controller (two donuts png and one Simpson image). Are there any solutions that I can capture these images as one image and save it to photo library? Thanks.

推荐答案

尝试一下,传入包含您需要的所有子视图的基本视图:

Try this, passing in the base view that has all the subviews you need:

func createImage(from aView:UIView) -> UIImage {
    UIGraphicsBeginImageContextWithOptions(CGSize(width: aView.frame.width, height: aView.frame.height), true, 0)
    aView.layer.render(in: UIGraphicsGetCurrentContext()!)
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return image!
}

这篇关于如何将几张图像作为一个图像快速保存到照片库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆