title: Change tint image color when pressing uibutton in Swift
body: <p>I have a scrollview inside a view. Inside the scrollview I create programmatically 5 buttons. Every button loads a different image with a different tag each one. I added a function that is called when pressing the buttons.</p>
  
  <pre><code>let avatarsListScrollingView = avatarsListView(CGSizeMake(70.0, 55.0), avatarCount: 5)
  
  
  func avatarsListView(buttonSize:CGSize, avatarCount:Int) -&gt; UIView {
  
   **CODE**
  
      for i in 0...(avatarCount-1)  {
          let button = UIButton(type: .Custom)
  
          **CODE**
  
          button.setImage(UIImage(named: avatarsList[i]), forState: .Normal)
  
          button.tag = i
          button.addTarget(self, action: "avatarListSelected:", forControlEvents: .TouchUpInside)
  
          avatarButtonView.addSubview(button)
      }
      return avatarButtonView
  
  }
  </code></pre>
  
  <p>Then when pressing the buttons, I call to "avatarListSelected":</p>
  
  <pre><code>func avatarListSelected(sender:UIButton){
  
      if let image = sender.imageView?.image?.imageWithRenderingMode(.AlwaysTemplate) {
          sender.setImage(image, forState: .Normal)
          sender.tintColor = UIColor.redColor()
      }
      self.addAvatarView.reloadInputViews()
  }
  </code></pre>
  
  <p>This function tints the image button to red, it is working fine, but the problem is that when I press some other button, I want the other one goes to the original color. Right now every button that I press gets in red.</p>
  
  <p>I tried to add the call to "self.addAvatarView.reloadInputViews()" to try to "redraw" again all the buttons, but never gets called.</p>
  
  <p>Do you guys know some way to do this?</p>