以下の内容はhttps://fromatom.hatenablog.com/entry/2017/07/14/222855より取得しました。


Swiftで透明なUIImageを生成する

毎回忘れるのでメモ

private func toumeiImage(size: CGSize) -> UIImage? {
    UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale)
    guard let context = UIGraphicsGetCurrentContext() else {
        return nil
    }

    // 背景を透明で塗りつぶす
    context.setFillColor(UIColor.clear.cgColor)
    let rect = CGRect(origin: .zero, size: size)
    context.fill(rect)

    // 画像に変換する
    let toumeiImage = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()

    guard let image = toumeiImage else {
        return nil
    }

    return image
}



以上の内容はhttps://fromatom.hatenablog.com/entry/2017/07/14/222855より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14