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];
最佳答案
尝试添加按钮的BackgroundColor
和TitleColor
:
[button setBackgroundColor:[UIColor greenColor]];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
关于ios - 显示了 uitextfield 但未显示按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37672996/