开发者

Buttons in Iphone

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜