Programming/iOS - ObjC
UIAlertView - TextField 추가
Tez.Park
2015. 7. 9. 14:51
UITextField *textField;
UITextField *textField2;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Username and password"
message:@"\n\n\n" // 중요!! 칸을 내려주는 역할을 합니다.
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Enter", nil];
textField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 25.0)];
[textField setBackgroundColor:[UIColor whiteColor]];
[textField setPlaceholder:@"username"];
[alert addSubview:textField];
textField2 = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 85.0, 260.0, 25.0)];
[textField2 setBackgroundColor:[UIColor whiteColor]];
[textField2 setPlaceholder:@"password"];
[textField2 setSecureTextEntry:YES];
[alert addSubview:textField2];
// AlertView의 위치를 이동 시켜 줌.
[alert setTransform:CGAffineTransformMakeTranslation(0.0, 110.0)];
[alert show];
[alert release];
// textfield에 커서를 보내고 키보드를 표시 해 줌.
[textField becomeFirstResponder];
반응형