Reputation: 5051
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.
Upvotes: 4
Views: 20075
Reputation: 21
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];
Upvotes: 2
Reputation: 31
In Interface Builder you can choose a Custom button and then set the Image property to your image. Don't use Rounded rect button, it will show behind the image.
Upvotes: 1
Reputation: 79770
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!!!
Upvotes: 10
Reputation: 716
Programatically, you can do something like this... http://www.iphonedevsdk.com/forum/iphone-sdk-development/1891-changing-button-image-code.html
Upvotes: 1