views:

4175

answers:

3

Hi,

I want to use image buttons in my iPhone application. Could you please let me know if there is any article I can read on this.

Thanks.

+1  A: 

Programatically, you can do something like this... http://www.iphonedevsdk.com/forum/iphone-sdk-development/1891-changing-button-image-code.html

danvin
+2  A: 

So the suggestion from http://www.iphonedevsdk.com/forum/iphone-sdk-development/1891-changing-button-image-code.html is:

UIButton *btn = [[UIButton alloc] init];
UIImage *img = [UIImage imageNamed:@"image.png"];
[btn setImage:img forState:UIControlStateNormal]
[img release];
stefanB
my image is round. When I load the image in the button, it shows rectangular button and the image on it. However, I just want to show the image, not the border of the button. Could you let me know how can I do that?
ebaccount
Don't release `img`.
Alex Reynolds
A: 

you dont need to release img. So the correct code could be -

UIButton *btn = [[UIButton alloc] init]; UIImage *img = [UIImage imageNamed:@"image.png"]; [btn setImage:img forState:UIControlStateNormal];