– (void)viewDidLoad{[super viewDidLoad];self.view.backgroundColor = [UIColor greenColor];// Do any additional setup after loading the view.UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(40, 40, 240, 40)];textField.borderStyle = UITextBorderStyleRoundedRect;textField.placeholder = @"请输入:";textField.clearButtonMode = UITextFieldViewModeAlways;textField.keyboardType = UIKeyboardTypeNumberPad;textField.returnKeyType = UIReturnKeyDone;//自定义键盘 可以看出来自定义键盘只与高度有关 其他不影响自定义键盘的位置大小UIView * keyboardView = [[UIView alloc] initWithFrame:CGRectMake(0, 1, 1, 100)];keyboardView.backgroundColor = [UIColor redColor];//把view赋值给inputViewtextField.inputView = keyboardView;//设置二级键盘UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(1, 1, 320, 20)];label.text = @"男";label.backgroundColor = [UIColor grayColor];textField.inputAccessoryView = label;[self.view addSubview:textField];}
效果图如下
版权声明:本文为博主原创文章,未经博主允许不得转载。
,他们的快乐像贪玩的小孩,游荡到天光却还不肯回来。