简体   繁体   中英

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.

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!!!

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];

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.

但你需要释放按钮;)[btn release];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM