将键盘扩展中的图像保存到剪贴板,以便用户在 Swift 中将其粘贴到文本字段中

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

能否请您提供 swift 中用于将图像保存到剪贴板的代码以及如何实现它。 如果有相关的教程也很好

简短示例:

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

有关更多信息,请查找 UIPasteboard Class 参考:http://goo.gl/NaSt8z

PS :您可能必须在设备上而不是模拟器上进行测试。