title: How to release background image of UIButton?
body: <p>Can anyone tell me how to release the image which is used as background image in UIButton. I created Custom button using following code but i could not able to release the memory of UIImage which is set a background image in the UIButton. Here is code which i used to create UIButton</p>
  
  <p>`</p>
  
  <pre><code>   for (int index=0;index&lt;10; index++)
  
     {            
      UIImage *image=[[UIImage alloc] initWithData:imageData];
  
  
      CGRect frame = CGRectMake(xValue, 10, 50, 50);  
      UIButton *button = [[UIButton alloc] initWithFrame:frame];
  
      [button addTarget:self action:@selector(onClickImgButton:)forControlEvents:UIControlEventTouchUpInside];
      [button setTag:index];      
      [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];     
      [button setImage:image forState:UIControlStateNormal];                      
      [button.layer setCornerRadius:10.0f];
      [button.layer setMasksToBounds:YES];
      [button.layer setBorderWidth:3.0f];
      [button.layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
  
      image=nil;
      [image release];
  
  
      [horizontalScrollView addSubview:button];
      button=nil; 
      [button release];
  
  
      xValue=xValue+60;
      cx +=60;
  }
  </code></pre>
  
  <p>`  </p>