title: Programmatically set image and text on UIButton
body: <p>I need to create button programatically with an image for normal and highlighted state as well text. I cannot build it using Interface Builder, because I need to create buttons over a <code>UIScrollView</code>. Here is the code I have so far:</p>
  
  <pre><code>- (void)loadView {
      CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
      scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];
      scrollView.contentSize=CGSizeMake(320,960);
  
      UIImageView *tempImageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.jpeg"]];
  
      UIImage * buttonImage = [UIImage imageNamed:@"contentlist_active.png"];
  
      self.view=scrollView;
      [scrollView addSubview:tempImageView2];
  
      btn = [UIButton buttonWithType:UIButtonTypeCustom];
      btn.frame = CGRectMake(22, 100, 277, 32);
  
      [btn setImage:buttonImage forState:UIControlStateNormal]; 
  
      [btn setTitle:@"hello world" forState:UIControlStateNormal];
      [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  
      [scrollView addSubview:btn];
  
  }
  </code></pre>
  
  <p>But the text on the button is not showing. If I comment out the <code>setImage</code> for <code>button</code>, then text shows perfectly, otherwise not. Can I have both text and an image at the same time?</p>