title: Make a UIActivityIndicator with background, position centre of the main View in Swift
body: <p>So What I am aiming for, is a UIActivityIndicator to position in the centre of the screen, with a background around the spinner, and then with a full background at half transparency. This image shows what I am trying to create:</p>
  
  <p><a href="https://i.stack.imgur.com/DdG4N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DdG4N.png" alt="enter image description here"></a></p>
  
  <p>I have no issues with the spinner etc, but getting the layers all positioned correctly. They all seem to sit below the centre. Please see the image below of what is actually happening:</p>
  
  <p><a href="https://i.stack.imgur.com/00cYX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/00cYX.png" alt="enter image description here"></a></p>
  
  <p>The code is below:</p>
  
  <pre><code>var spinningActivityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
  
      let container: UIView = UIView()
      container.frame = self.view.frame
      container.center = self.view.center
      container.backgroundColor = UIColor(hue: 0/360, saturation: 0/100, brightness: 0/100, alpha: 0.4)
  
      let loadingView: UIView = UIView()
      loadingView.frame = CGRectMake(0, 0, 80, 80)
      loadingView.center = self.view.center
      loadingView.backgroundColor = UIColor(hue: 359/360, saturation: 67/100, brightness: 71/100, alpha: 1)
      loadingView.clipsToBounds = true
      loadingView.layer.cornerRadius = 40
  
      spinningActivityIndicator.frame = CGRectMake(0, 0, 40, 40)
      spinningActivityIndicator.hidesWhenStopped = true
      spinningActivityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge
      spinningActivityIndicator.center = CGPointMake(loadingView.frame.size.width / 2, loadingView.frame.size.height / 2)
      loadingView.addSubview(spinningActivityIndicator)
      container.addSubview(loadingView)
      view.addSubview(container)
      spinningActivityIndicator.startAnimating()
      UIApplication.sharedApplication().beginIgnoringInteractionEvents()
  </code></pre>
  
  <p>Can anyone help me fix this issue? Thanks!</p>