简体   繁体   中英

How to show a image background when button is scelected or clicked

i have this code in the button click to show selection image when the button is clicked

 UIImage *img1 = [UIImage  imageNamed:@"settingpress.png"];

             [_btnclick setImage:img1 forState:(UIControlStateHighlighted+UIControlStateSelected)];

             [img1 release];

but i didn't get the image ,my button is a UIButton in xib with custom button not the Roundrect.what is the error in my code. thanks in advance.

You have to use background Image and the | separator:

[_btnclick setBAckgroundImage:img1 forState:(UIControlStateHighlighted|UIControlStateSelected)];

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