以下代码基本上可以正常工作,只显示结果时不显示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)
我真的不知道是什么原因引起的.
[myButton setTitle:@"Contact Someone!" forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
705 次 |
| 最近记录: |