iPhone SDK: Can a UIButton with custom images display the title?
- by Harkonian
If I create a custom UIButton with images for UIControlState normal and UIControlStateSelected, am I still supposed to be able to display the title for the button? Currently I can't. This is how I create my button:
UIImage *moveButtonImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"button_move_inactive" ofType:@"png"] ];
UIImage *moveButtonSelectedImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"button_move_pressed" ofType:@"png"] ];
self.moveButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.moveButton setImage : moveButtonImage forState : UIControlStateNormal];
[self.moveButton setImage : moveButtonSelectedImage forState : UIControlStateSelected];
[self.moveButton setTitle:@"Test" forState:UIControlStateNormal];
The button title never displays in this case and I'm forced to create my own label to display on the button, which seems like a hacky way of doing things. Maybe I'm doing something wrong here?