Ich habe CAShapeLayers in meinem UIView und ich möchte UIImage aus der Sicht.
So unten Funktion durch Ich versuche aber einen Fehler bei
UIGraphicsGetCurrentContext()Swift Get UIImage von Schichten von UIView
extension UIView
{
func getImgFromVyuFnc() -> UIImage
{
UIGraphicsBeginImageContext(self.frame.size)
self.layer.renderInContext(UIGraphicsGetCurrentContext())
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
}
fatal error: unexpectedly found nil while unwrapping an Optional value 2017-08-17 04:17:47.230474 PicPac[1095:488887] fatal error: unexpectedly found nil while unwrapping an Optional value
Das wahrscheinlichste Problem ist, dass 'self.frame.size' in einer oder beiden Dimension (en) null ist. – idz
Ich bin froh, dass ich helfen konnte. Gepostet als Antwort jetzt. Viel Glück mit deiner App! – idz