'How to change the background color of a UIButton when tapped in swift?

ViewController: UIViewController {
   @IBAction func like(sender: AnyObject) {
       like(backgroundColor!) = UIColor.greenColor()
   }
}

I want to chanage the color of UIbutton"like button" : White is the default "not tapped or unlike" green when is tapped.

How do you change a buttons background colour when it is tapped using Swift?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source