Created
December 8, 2021 01:30
-
-
Save tsuzukihashi/167ad67500ee940acf5d01317ce7ca5b to your computer and use it in GitHub Desktop.
UIViewをUIImageに変換するExtension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIView { | |
var uiImage: UIImage { | |
let imageRenderer = UIGraphicsImageRenderer.init(size: bounds.size) | |
return imageRenderer.image { context in | |
layer.render(in: context.cgContext) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment