2016-01-22 35 views
0

如何在Objective C-Xcode 7.1中將標籤圖像保存到UIPasteboard/Clipboard中? 我試過這段代碼,但它只複製文本。如何將標籤的圖像保存到UIPasteboard? Xcode

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

有沒有複製圖像,甚至只是複製圖像的自我?

回答

0

是的,你可以做到。

您需要使用下面的方法把一個圖像到本機的iOS紙板:

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

你也可以把UIImages的數組UIPasteboard:

[[UIPasteboard generalPasteboard] setImages:arrayOfImages]; 

要了解更多信息你可以閱讀蘋果UIPasteboard class reference.

相關問題