UIButton *okBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
okBtn.frame = CGRectMake(61, 210, 200, 30);
[okBtn setTitle:@"OK Button" forState:UIControlStateNormal];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 100, 24)];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.text = @"label1";
//// 텍스트 필드
UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 100, 24)];
tf.backgroundColor = [UIColor blueColor];
tf.borderStyle = UITextBorderStyleLine;
// CGRectMake의 1, 2인수는 시작점. 3,4인수는 프레임의 크기.
UITextField *tf1 = [[UITextField alloc] initWithFrame:CGRectMake(10, 40, 100, 24)];
tf1.backgroundColor = [UIColor whiteColor];
tf1.borderStyle = UITextBorderStyleLine;
[self.view addSubview:tf];
[self.view addSubview:tf1];
UITextField *textField;
for (int i=0; i < 5; i++){
textField =
[[UITextField alloc] initWithFrame:CGRectMake(10, 10 + 30 * i, 100, 24)];
textField.borderStyle = UITextBorderStyleLine;
textField.tag = i;
//생성된 컨트롤러의 접근을 위해 태그 붙임.
[self.view addSubview:textField];
}
UITextField *tf = [self.view viewWithTag:3];
tf.text = @"tag access";
[tf addTarget:self action:@selector(endEditing:) forControlEvents:UIControlEventEditingDidEnd];
- (void) endEditing:(id)sender{
//or (IBAction)
//Code만으로 할때는 void리턴타입이어도 됨. 파라메터에 주의.
NSLog(@"endEditing...");
}