title: UIBarButtonItem changing image for Play/Pause button
body: <p>I'm trying to make a play/pause button that toggles between custom images as it is pressed. Here is a snippet of the code.</p>
  
  <p>Everything works fine but the button doesn't change. I've also tried using the .image property instead of the .setBackGroundImage method but then the button just goes blank on click.</p>
  
  <p>Here is the code</p>
  
  <pre><code>import UIKit
  import AVFoundation
  
  class ViewController: UIViewController {
  
  var audioPlayer = AVAudioPlayer()
  
  var pauseImage:UIImage?
  var playImage:UIImage?
  
  @IBOutlet weak var btnPlayPause: UIBarButtonItem!
  
  @IBOutlet weak var sldVolume: UISlider!
  
  @IBAction func sldVolumeChanged(sender: AnyObject) {
  
      audioPlayer.volume = sldVolume.value
  
  }
  
  @IBAction func actPressedPlayPause(sender: AnyObject) {
  
      if audioPlayer.playing {
          audioPlayer.pause()
          btnPlayPause.setBackgroundImage(playImage, forState: .Normal, barMetrics: .Default)
  
      } else {
          audioPlayer.play()
          btnPlayPause.setBackgroundImage(pauseImage, forState: .Normal, barMetrics: .Default)
      }
  
  }
  
  @IBAction func actStopPressed(sender: AnyObject) {
  
      audioPlayer.stop()
      audioPlayer.currentTime = 0
  
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      var pauseImagePath = NSBundle.mainBundle().pathForResource("pause", ofType: "png")
      pauseImagePath = pauseImagePath!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
      pauseImage = UIImage(contentsOfFile: pauseImagePath!)
  
      var playImagePath = NSBundle.mainBundle().pathForResource("play", ofType: "png")
      playImagePath = playImagePath!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
      playImage = UIImage(contentsOfFile: pauseImagePath!)
  
  
  
      var audioPath = NSBundle.mainBundle().pathForResource("minuetcminor", ofType: "mp3")
  
      audioPath = audioPath!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
  
      var error : NSError? = nil
  
      audioPlayer = AVAudioPlayer(contentsOfURL: NSURL(string: audioPath!), error: &amp;error)
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  
  }
  </code></pre>