I’ve got an Custom UIButton. It’s got
- a “static” background image
- a variable text (the Title) which gets set in the code
Now I would like to add an icon (UIImage/UIImageView) inside the button on the left of the text. (I use the indent to move the text slightly to the right). Is there an easy way of adding that icon (and referencing it from code, so I can change it) or would you recommend creating a completely new button e.g. based on a UIView? (e.g. a view, that responds to touches)?
I’m just trying to get a feel for what the best approach would be for this. Any experience?
Two ways:
drawRect:what I really like because it makes your app soooooo much faster!addSubview:. If you save it in your main-class (@property (...) UIButton *button) you can always access it by calling[self button]. You can also subclass your UIButton and add this@property. That’s up to you.It’s totally up to you. However I prefer the first way!