Ahti
Ahti

Reputation: 1430

UIButton does not show titleLabel

The following code basically does work, only the titleLabel is not shown when the result is displayed.

buttonRectis just a CGRect containing the buttons frame. I don't think the cause of the problem is there, because the button is displayed at the position he should be at.

[contactButton.titleLabel center] did not help, bringing the subview titleLabel to front didn't either.

UIButton *contactButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
contactButton.frame = buttonRect;

contactButton.titleLabel.text = @"Contact Someone!";
[contactButton addTarget:self action:@selector(showContactWindow) forControlEvents:UIControlEventTouchUpInside];

[self.tabBarController.view addSubview:contactButton];

I really have no idea what could be causing this.

Upvotes: 1

Views: 722

Answers (1)

kovpas
kovpas

Reputation: 9593

[myButton setTitle:@"Contact Someone!" forState:UIControlStateNormal];

Upvotes: 5

Related Questions