Reputation: 522
I'm developing a custom keyboard and I want to be able to copy the button image to clipboard (it's a png image). I've already tried something like UIPasteboard.generalPasteboard().image = UIImage(named: "dMk87zJ.png")
when the button is pressed, but it doesn't work. I was only able to accomplish that with text. What am I doing wrong ?
Upvotes: 3
Views: 4284
Reputation: 1273
Please use below code for copy and paste images.
NSData *data = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:data forPasteboardType:@"public.png"];
Its perfect work in all apps which allow paste functionality. Especially Notes app.
For UTI types use this link
Don't use below code
[UIPasteboard generalPasteboard].image = image;
I face issue with Notes app with this line of code to copy png image
Upvotes: 7