I have a UIButton subclass that I initialize as:
MyButton *button = [MyButton buttonWithType:UIButtonTypeCustom];
I want to set the background color of this button.
If I do the following in the view controller after creating the button:
MyButton.backgroundColor = [UIColor ...];
It works fine. But if I try to do the following within the UIButton
subclass, either in initWithFrame
or in DrawRect:
self.backgroundColor = [UIColor ...];
It simply does nothing. The button remains transparent.
The thing is, my logic is such that I really need to set the color inside the UIButton subclass, not in the calling code.
Any ideas?