UIAlertController image



  • How do we add a picture to UIAlertController?

     let alertController = UIAlertController(title: "Hey", message: "My Image:", preferredStyle: .Alert)
    
        alertController.view.subviews.first?.subviews.first?.backgroundColor = UIColor(red: 90.0, green: 70.0, blue: 255.0, alpha: 0.1)
        alertController.view.subviews.first?.subviews.first?.layer.cornerRadius = 10
        alertController.view.tintColor = UIColor.blueColor()
    
        alertController.addAction(UIAlertAction(title: "Ok", style: .Default) { action in
            let scene = ProgressScene(fileNamed: "GameScene")!
            self.view?.presentScene(scene, transition: SKTransition.flipHorizontalWithDuration(0.3))
            })
        
        self.view?.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)</code></pre></div></div></p>


  • We can do this:

    let image = UIImage(named: "myAlertImage")
    var action = UIAlertAction(title: "title", style: .Default, handler: nil)
    action.setValue(image, forKey: "image")
    alertController.addAction(action)
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2