0

How can you save a label's image to a UIPasteboard / Clipboard in Objective C - Xcode 7.1? I've tried this code bellow, but it only copies the text.

[UIPasteboard generalPasteboard].string = helloField.text;
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"paste me somewhere";

Is there away to copy the image as well or even just copying the image by its self?

James
  • 47
  • 11

1 Answers1

0

Yes, you can do it.

You need to use the following method to put one image to the native iOS Pasteboard:

UIImage *image = [UIImage imageNamed:@"img.png"];    
[[UIPasteboard generalPasteboard] setImage:image];

You also can to put array of UIImages to UIPasteboard:

[[UIPasteboard generalPasteboard] setImages:arrayOfImages];

To learn more information you can read the Apple UIPasteboard class reference.

Oleksandr Balabanov
  • 629
  • 1
  • 6
  • 30