title: Swift3: Add button with code
body: <p>Im reading Apples swift (iOS) documentation but its written for Swift 2 and i use Swift 3. I want to add a button programmatically but its seems there is a change and I can't find how to fix it.</p>
  
  <p>Here is the Code for the Swift 2 example:</p>
  
  <pre><code>import UIKit
  
  class RatingControl: UIView {
  
  // MARK: Initialization
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  
      // Buttons
      let button = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
      button.backgroundColor = UIColor.red()
      button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(_:)), forControlEvents: .TouchDown)
      addSubview(button)
  }
  
  override func intrinsicContentSize() -&gt; CGSize {
      return CGSize(width: 240, height: 44)
  }
  
  // MARK: Button Action
  
  func ratingButtonTapped(button: UIButton){
      print("Button pressed")
  }
  }
  </code></pre>
  
  <p>The only change i made after the 'fix-it' showed the error is this in the selector:</p>
  
  <pre><code>button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(button:)), for: .touchDown)
  </code></pre>
  
  <p>This should have printed "Button pressed" but it doesn't. Any help?</p>