美文网首页
iOS - Context to Image

iOS - Context to Image

作者: ienos | 来源:发表于2022-07-24 11:34 被阅读0次

    通过画布生成图片

    func createImage(size: CGSize) -> UIImage? {
        UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale)
        guard let context = UIGraphicsGetCurrentContext() else { return nil }
        draw(context: context, size: size)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image
    }
    

    相关文章

      网友评论

          本文标题:iOS - Context to Image

          本文链接:https://www.haomeiwen.com/subject/hswiirtx.html