Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone image button

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.

like image 448
ebaccount Avatar asked Dec 09 '22 20:12

ebaccount


2 Answers

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]
//No need to release img. It is autoreleased!!!
like image 185
stefanB Avatar answered Dec 24 '22 18:12

stefanB


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];
like image 35
user382968 Avatar answered Dec 24 '22 18:12

user382968