UIButton不显示titleLabel

Aht*_*hti 1 objective-c

以下代码基本上可以正常工作,只显示结果时不显示titleLabel.

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

[contactButton.titleLabel center] 没有帮助,将子视图标题标题拉到前面也没有.

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];
Run Code Online (Sandbox Code Playgroud)

我真的不知道是什么原因引起的.

kov*_*pas 6

[myButton setTitle:@"Contact Someone!" forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)