title: UIAlertController foreground is dimmed when it should not be
body: <p>I have a strange issue which is affecting all of many UIAlertControllers shown throughout my app - the AlertControllers' white foreground appears dimmed, or less bright, than it should be. </p>
  
  <p>The easiest way to describe it is to illustrate the desired and expected effect I obtain by placing the relevant code in a fresh 'Test' Single View application (Swift 3 - I should note that the actual app is a Single View application using Swift 2.3).</p>
  
  <p>In my 'Test' app, the code below uses a deprecated AlertView to show a sample message, then builds a AlertController and shows that immediately 'after'.  There is no need to use the AlertView except to highlight the contrast in foreground 'white' - the problematic behaviour is the same if I comment out the AlertView.</p>
  
  <p>Problematic behaviour:
  <a href="https://i.stack.imgur.com/wCs5u.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wCs5u.jpg" alt="4 images comparing alertcontroller in Test app vs real app"></a></p>
  
  <p>Image 1: Test app: the AlertView is shown and the AlertController then shows behind it. Note the whiteness/brightness of the AlertView foreground.</p>
  
  <p>Image 2: Test app: when the AlertView is dismissed, the AlertController is then the uppermost viewcontroller and as expected and desired, its foreground brightness is exactly the same as the AlertView's previously was</p>
  
  <p>Image 3: real app: same code, also positioned in viewDidAppear - the AlertView is shown with the expected whiteness/brightness</p>
  
  <p>Image 4: real app: when the AlertView is dismissed, the AlertController is then uppermost, but its foreground is nowhere near as bright / white as the AlertView's was, OR as it was in the Test app example, image 2.</p>
  
  <p>As previously stated, the behaviour is the same even if I eliminate the AlertView step (which is just for contrast).</p>
  
  <p>One further observation - often when I observe the behaviour, just momentarily when an affected AlertController first appears, as in for maybe 1/4 or 1/8 of a second, its foreground is the correct whiteness/brightness, but then an instant later it becomes dimmed, per the stated problem.</p>
  
  <p>One other observation - some AlertControllers in the real app display properly with the correct level of brightness, but many others do not.</p>
  
  <p>One last observation - I have user the 'View UI Hierarchy' in Xcode and there does not appear to be anything 'on top of' the affected AlertController.</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  }
  
  
  override func viewDidAppear(_ animated: Bool) {
  
  
      UIAlertView(title: "My AlertView Title", message: "My AlertView Message", delegate: self, cancelButtonTitle: "OK").show()
  
      let alertTitle = "My AlertController Title"
      let msg = "\r\r\r\r\r\r\r\rMy AlertController Msg"
  
      let alertController = UIAlertController(title: alertTitle, message: msg, preferredStyle: .alert)
  
      let cancelAction = UIAlertAction(title: "Don't show this again", style: .cancel) { (action:UIAlertAction!) in
          print("Dismiss button pressed")
  
      }
      alertController.addAction(cancelAction)
  
      let OKAction = UIAlertAction(title: "Action 1", style: .default) { (action:UIAlertAction!) in
  
          print("I'm action1!!")
      }
  
      alertController.addAction(OKAction)
  
      let OK2Action = UIAlertAction(title: "Action2", style: .default) { (action:UIAlertAction!) in
  
          print("I'm action2")
      }
  
      alertController.addAction(OK2Action)
  
      present(alertController, animated: false, completion: nil)
  
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any help as to this puzzle gratefully received, thanks!</p>
  
  <p>EDIT:</p>
  
  <p>thanks to @Richard G for putting me on the right track - I still have the problem but with more clarity. </p>
  
  <p>So, it you look at the two screenshots below side by side, they are both from the real app, both use the code shown above to generate the UIAlertController (I have now delete the UIAlertView line as it isn't needed), the only difference between the one on the left and one on the right is the one on the right has these 3 lines of code added:</p>
  
  <pre><code>let backView = alertController.view.subviews.last?.subviews.last 
  backView?.layer.cornerRadius = 10.0 
  backView?.backgroundColor = UIColor.whiteColor()  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/r8IiI.jpg" rel="nofollow noreferrer">side by side UIAlertControllers 1 transparent 1 not</a></p>
  
  <p>According to Apple, "The UIAlert​Controller class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified."  OK, so this is hacking into it, and it proves that somehow the alertController has acquired, prior to displaying it, a backgroundColor which was partly transparent.</p>
  
  <p>By setting the backgroundColor to UIColor.whiteColor() the problem is fixed, but the solution should be unnecessary - how on earth did the problem arise in the first place? </p>
  
  <p>How was the backgroundColor somehow set to have a transparency when Apple doesn't even expose that property to me to be able to set?</p>
  
  <p>any answers gratefully received!</p>