这是我的警报,完美无缺.我想在警报显示时向警报添加一个图像,如果它有所不同,我会在SpriteKit中的SKScene中.
var alertController = UIAlertController(title: "How to Skate", message: "Tap the screen to perform a trick and jump over the obsticles (You can grind on rails) The game will end when you hit a highlighted red, orange or yellow obstacle. That's it! + Image", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "Cool!", style: UIAlertActionStyle.Cancel, handler: nil))
self.view?.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
Abh*_*nav 10
您可以将a UIImageView作为子视图添加到您的UIAlertController.
var imageView = UIImageView(frame: CGRectMake(220, 10, 40, 40))
imageView.image = yourImage
alert.view.addSubview(imageView)
Run Code Online (Sandbox Code Playgroud)
您是这样做的UIAlertController:
let alertMessage = UIAlertController(title: "My Title", message: "My Message", preferredStyle: .Alert)
let image = UIImage(named: "myImage")
var action = UIAlertAction(title: "OK", style: .Default, handler: nil)
action.setValue(image, forKey: "image")
alertMessage .addAction(action)
self.presentViewController(alertMessage, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
let alertMessage = UIAlertController(title: "My Title", message: "", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
action.setValue(UIImage(named: "task1.png")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal), forKey: "image")
alertMessage .addAction(action)
self.present(alertMessage, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
斯威夫特 3
| 归档时间: |
|
| 查看次数: |
16053 次 |
| 最近记录: |