2011-03-10 120 views
1

下面的代码基本上可以工作,只显示结果时不显示titleLabel。UIButton不显示titleLabel

buttonRect只是一个包含按钮帧的CGRect。我不认为问题的原因在那里,因为按钮显示在他应该在的位置。

[contactButton.titleLabel center]没有帮助,使子视图titleLabel前面也没有。

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]; 

我真的不知道是什么原因导致这种情况。

回答

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