Is it possible to manually assign an image to a button in the iphone sdk. What i wish to do is to assign a plain card background to a button. When a user clicks the button a picker appears the user makes a selection with the picker the buttons image will to the card selected? I have开发者_JS百科 all the cards saved in my resources already.
Try the fiollowing code:
btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:[UIImage imageNamed:@"any.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"any_on.png"] forState:UIControlStateHighlighted];
You can use image in image view then over this image use an custom button and on click this button an IBAction will call suppose -(IBAction)call { myPicker.hidden=NO; } and in viewWillAppear myPicker.hidden=YES;
And use picker view delegate methods for your logic for picker view.
精彩评论