2017-04-15 6 views
0
私はUIViewのを追加 にしたい

にUIImageViewでのUIViewを追加する方法UIImageViewに(UIViewのは、一部の画像やテキストを含む持っていた)、そのImageViewのは、私は私のカメラロールに保存したいです。この問題を解決するのに役立つ提案やスナップコードを教えてください。私の場合はClick Here For UIScreenは、iOS Objective Cの

私は1枚のUIViewとワンUIImageViewステッカーのUIViewに追加があると私はそれらをマージしたいと屋私は風景モードで画像をしたい

すべてのヘルプや提案を感謝することができます。

ありがとうございました。

+0

これをチェックしてください。http://stackoverflow.com/questions/30696307/how-to-convert-a-uiview-to-a-image – iOS

答えて

0

私は、同様のタスクを持っていたし、このコードを使用:

func getResultImage() throws -> (image: UIImage, path: URL) { 
    UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.main.scale) 
    defer { 
     UIGraphicsEndImageContext() 
    } 
    drawHierarchy(in: self.bounds, afterScreenUpdates: true) 

    guard let image = UIGraphicsGetImageFromCurrentImageContext() else { 
     throw ImageEditorViewError.noImageGenerated 
    } 

    guard let data = UIImagePNGRepresentation(image) else { 
     throw ImageEditorViewError.noDataRepresentation 
    } 

    let writePath = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("Image.png") 

    try data.write(to: writePath) 

    return (image, writePath) 
} 

は、このコードは、あなたのコンテナビュー内であることを、仮定私の仕事のために特異的であったとしてあなたは、writePahtとの一部を削除することができますあなたの中にいくつかのビューステッカーがあります。

+0

あなたの答えはありがたいですが、私は働いています客観的なcの上で迅速に。それは私の問題を解決しない –