
Hi,
How to create uibutton with background image?
Thanks

Hi,
Here is the code example:
CGRect frame = CGRectMake(0, 0, 80, 40);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTag:j];
button.frame = frame;
//set images
UIImage * imgNormal = [UIImage imageNamed:@"subtabButton.png"];
[button setBackgroundImage:imgNormal forState:UIControlStateNormal];
UIImage * imgSelected = [UIImage imageNamed:@"subtabButton_selected.png"];
[button setBackgroundImage:imgSelected forState:UIControlStateSelected];
[button setBackgroundImage:imgSelected forState:UIControlStateHighlighted];
[button setTitle:@"My Button" forState:UIControlStateNormal];
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.