ios - 显示了 uitextfield 但未显示按钮

标签 ios uibutton

UITextField 已显示,但未显示 UIButton。 如何显示按钮??

UITextField *password = [[UITextField alloc] initWithFrame:CGRectMake(30.0, 150, 300, 30.0)];
password.delegate = self;
[password setBorderStyle:UITextBorderStyleRoundedRect];
[password setClearButtonMode:UITextFieldViewModeAlways];
password.placeholder = @"Password";
[password setFont:[UIFont systemFontOfSize:10]];
[self.view addSubview:password];
//button
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(30, 200 , 50, 50)] ;
[button addTarget:self action:@selector(clicked) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button = [UIButton buttonWithType: UIButtonTypeSystem];

 [self.view addSubview:button];

最佳答案

尝试添加按钮的BackgroundColorTitleColor:

[button setBackgroundColor:[UIColor greenColor]];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

关于ios - 显示了 uitextfield 但未显示按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37672996/

相关文章:

ios - 根据 UIButton 的标题调整其宽度

ios - 使用 iOS 库时 Storyboard View 未连接

ios - Swift - 如何在设置后更改 UIButton 的 NSMutableAttributedString 的颜色

ios - Swift: View Controller 中的自定义 UIButton 类触摸事件未触发?

ios - XMPPFramework - 获取重复消息

swift - 如何重写(太大)IF 语句的代码?

ios - 如何创建一个 UIView,根据按下显示 View 的按钮来显示某些信息?

iphone - 向 UIButton 添加声音的可靠方法

ios - 如何将数据从一个 View Controller 传递到另一个 SWIFT

ios - 为什么我的第一个回复是空的?