title: How to change the state of an UIButton in iOS using Swift?
body: <p>I have Objective-C working code for six buttons but I don't seem to find how to change the state of a button using Swift. So how do I make the following code work in Swift?</p>
  
  <pre><code>[self.button2 setBackgroundImage:[UIImage imageNamed:@"button2_selected.png"] forState: UIControlStateSelected];
  button1.selected = NO;
  button2.selected = !button2.selected;
  button3.selected = NO;
  button4.selected = NO;
  button5.selected = NO;
  button6.selected = NO;
  </code></pre>