title: ios: Center view in its superview
body: <p>I'm trying to center <code>my subview</code> with a <code>button</code> in its<code>superview</code>. So I want the center of the <code>subview</code> be the center of the <code>superview</code>. I'm trying that with following code:</p>
  
  <pre><code>override func viewDidLoad() {
      self.view.backgroundColor = UIColor.redColor()
  
      var menuView = UIView()
      var newPlayButton = UIButton()
      //var newPlayImage = UIImage(named: "new_game_button_5cs")
      var newPlayImageView = UIImageView(image: UIImage(named: "new_game_button_5cs"))
      newPlayButton.frame = CGRectMake(0, 0, newPlayImageView.frame.width, newPlayImageView.frame.height)
      newPlayButton.setImage(newPlayImage, forState: .Normal)
      newPlayButton.backgroundColor = UIColor.whiteColor()
      menuView.center = self.view.center
      menuView.center = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2)
      menuView.backgroundColor = UIColor.whiteColor()*/
      menuView.addSubview(newPlayButton)
  }
  </code></pre>
  
  <p>Unfortunately it doesent seem to work as this is the result:</p>
  
  <p><img src="https://i.stack.imgur.com/JapUR.png" alt="enter image description here"></p>