title: Swift: How to subclass a UIButton?
body: <p>I want a simple class that changes the colour of  background and text on a button when its selected. </p>
  
  <p>I have got this : </p>
  
  <pre><code>class buttonSelected : UIButton {        
      override var highlighted: Bool {
          get {
              return super.highlighted
  
          }
          set {                
                  backgroundColor = UIColor(red: 0.27, green: 0.29, blue: 0.31, alpha: 1.0)
                  //backgroundColor = UIColor.whiteColor()
                  setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
                  println(tag)
                  super.highlighted = newValue
          }
      }        
  }
  </code></pre>
  
  <p>This subclassing works great. I manually add the tag to each individual button. 
  First question is why does the </p>
  
  <pre><code>pritnln(tag)
  </code></pre>
  
  <p>show twice ? </p>
  
  <p>Also whats the best way to revert this when the user presses on the button again. I cannot subclass highlighted again, and there is only selected, disabled left. I get this info by cmd over the highlighted text.</p>