Search code examples
swiftios8keyboardios8-extension

Save an image from keyboard extension to clipboard to make it ready to be pasted in a textfield by the user in Swift


Can you please provide me with the code in swift for saving an image to clipboard and how it should be implemented. If you have any related tutorial that would be great too.


Solution

  • Short example :

    let image = UIImage(named: "image.png")
    UIPasteboard.generalPasteboard().image = image;
    

    For more information, look for UIPasteboard Class Reference : http://goo.gl/NaSt8z

    PS : You might have to test that on device and not on simulator.