stackiphone
stackiphone

Reputation: 1245

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.

Upvotes: 0

Views: 62

Answers (1)

Antonio MG
Antonio MG

Reputation: 20410

You have to use background Image and the | separator:

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

Upvotes: 1

Related Questions