I'm manually setting the copied content in the pasteboard
@IBAction func onOkPressed( button: UIButton ) {
var testImage = getImageWithColor(UIColor.redColor(), size: CGSize(width: 100, height: 100));
UIPasteboard.generalPasteboard().image = testImage
}
func getImageWithColor(color: UIColor, size: CGSize) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill()
UIRectFill(CGRectMake(0, 0, 100, 100))
var image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
But when I paste the image into a textbox in simulator it doest not paste the image. I've tried this with a local png image as well instead of manually creating the image. When I paste onto the textbook in my custom keyboard app, it pastes the text from my mac clipboard instead of the image. However, if I programmatically do UIPasteboard.generalPasteboard().string = "TeST"
, the expect string gets pasted. Anyone know what could be wrong? Thanks.