(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新聞熱點
疑難解答