将图像添加到操作表
Add image to actionsheet
如何在 UIAlertController 中将 tableview 的屏幕截图添加到第一个 "action"?
我试着那样做
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let action = UIAlertAction(title: NSLocalizedString("Share routine", comment: ""), style: .default, handler: { _ in
})
action.setValue(image, forKey: "image")
actionSheet.addAction(action)
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil))
UIApplication.topViewController()?.present(actionSheet, animated: true, completion: nil)
action.setValue(myImage.withRenderingMode(.alwaysOriginal), forKey: "image")
我需要添加 .withRenderingMode(.alwaysOriginal)
<- 以获得正确的图像。感谢大家的帮助
我试过你的代码,发现了一些错误
首先,使用图片代替
image.withRenderingMode(.alwaysOrigin)
如果你想把你的图片放在某个位置,使用 imageView
如何在 UIAlertController 中将 tableview 的屏幕截图添加到第一个 "action"? 我试着那样做
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let action = UIAlertAction(title: NSLocalizedString("Share routine", comment: ""), style: .default, handler: { _ in
})
action.setValue(image, forKey: "image")
actionSheet.addAction(action)
actionSheet.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil))
UIApplication.topViewController()?.present(actionSheet, animated: true, completion: nil)
action.setValue(myImage.withRenderingMode(.alwaysOriginal), forKey: "image")
我需要添加 .withRenderingMode(.alwaysOriginal)
<- 以获得正确的图像。感谢大家的帮助
我试过你的代码,发现了一些错误
首先,使用图片代替
image.withRenderingMode(.alwaysOrigin)
如果你想把你的图片放在某个位置,使用 imageView