Reputation: 376
I need some help and advice on using multiple images simultaneously on the same custom UIButton.
Here is what I have:
...Ultimately, the number of buttons that could be created is vast...
Under the hood: There are a few template PNG files that I use to create the faces of the buttons. This article was of great help. These are the faces for normal and active state. The handling of dynamic creation and removal from view was done with the wonderful help I got from postings here!
QUESTION: Is there a way that I can use a third image (PNG with transparency) to have an icon or a symbol instead if the button textual title/label?
As you might have guessed, i would like to avoid having a huge number of unique hard-coded faces for each of the numerous buttons and would like to only add a small graphical symbol to the face of the dynamically generated and stretched button. IS THIS POSSIBLE?
Thank you!
Upvotes: 4
Views: 3098
Reputation: 4011
How about something like:
UIImageView *buttonImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"png_image_with_transparency.png"]];
[buttonImageView setFrame:CGRectMake(0.0f, 0.0f, button.frame.size.width, button.frame.size.height)];
[button addSubview:buttonImageView];
Hope that helps.
Upvotes: 1