如何向UITextField
添加两个UIToolbar
,如下所示?
答案 0 :(得分:2)
正如比尔所说! 看看你给出的图片,我认为它不是一个带有两个UITextField的UIToolbar。如果你想使用UIToolbar,你可以在没有IB的情况下编写它。代码如下:
UIToolbar *tool = [[UIToolbar alloc] initWithFrame:CGRectMake(40.0,0.0,400,180.0)];
UITextField *firstTextField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 10.0, 360.0, 60)];
firstTextField.backgroundColor = [UIColor whiteColor];
[firstTextField.layer setCornerRadius:18];
UITextField *secondTextField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 100.0, 360.0, 60)];
secondTextField.backgroundColor = [UIColor whiteColor];
[secondTextField.layer setCornerRadius:18];
secondTextField.borderStyle = UITextBorderStyleBezel;
[tool addSubview:firstTextField];
[tool addSubview:secondTextField];
[view addSubview:tool];
[tool release];
[firstTextField release];
[secondTextField release];
您可以更改UIToolBar和UITextFields的样式。
祝你好运!
答案 1 :(得分:0)
如果您使用IB将UIToolbar添加到视图中,您需要将UITextField拖到UIToolbar上。
答案 2 :(得分:0)
你不能用标准的UIToolbar。这是一个单行的事情。
但是你可以将它们添加到UIView,在那里你将渐变绘制为背景。看看UIView和Core Graphics。