(void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.
//初始化textfield并设置位置及大小 UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];
//设置输入框的背景颜色 text.backgroundColor = [UIColor redColor];
// 中点的x CGFloat centerX = self.view.frame.size.width * 0.5; CGFloat centerY = self.view.frame.size.height * 0.5; text.center = CGPointMake(centerX, centerY);
// 设置字体 text.font = [UIFont systemFontOfSize:30];
text.delegate = self;
//把textfield添加到视图上 [self.view addSubview:text];
}
//开始编辑时的方法 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ NSLog(@”a”);
//编写时背景颜色修改成绿色textField.backgroundColor = [UIColor greenColor];return YES;}
(void)touchesBegan:(NSSet新闻热点
疑难解答