title: change image of UIBarButton
body: <p>My target is to change the Image of an UIBarButton (which i use as IBOutlet) programmatically.</p>
  
  <p>I found this solution on stackoverflow <a href="https://stackoverflow.com/questions/1547188/change-image-of-uibutton-with-other-image">change-image-of-uibutton-with-other-image</a>. but this is not working on iOS 4.2. </p>
  
  <p>Can anyone help me with that.
  Simon</p>
  
  <p>I tried:</p>
  
  <pre><code>UIImage *image = [UIImage imageWithContentsOfFile: 
                   [[NSBundle mainBundle] pathForResource:@"play" ofType:@"png"]];
  playButton.image = image;
  </code></pre>
  
  <hr>
  
  <pre><code>UIImage *image = [UIImage imageWithContentsOfFile:
                   [[NSBundle mainBundle] pathForResource:@"play" ofType:@"png"]];UIImage *image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"play" ofType:@"png"]];
  CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
  UIButton* someButton = [[UIButton alloc] initWithFrame:frame];
  [someButton setBackgroundImage:image forState:UIControlStateNormal];
  [someButton setShowsTouchWhenHighlighted:YES];
  playButton = [[UIBarButtonItem alloc]initWithCustomView:someButton];
  
  [someButton release];
  </code></pre>