What's a simple way to get a text input popup dialog box on an iPhone

后端 未结 12 2074
-上瘾入骨i
-上瘾入骨i 2020-12-02 03:42

I want to get the user name. A simple text input dialog box. Any simple way to do this?

12条回答
  •  庸人自扰
    2020-12-02 04:38

    UIAlertview *alt = [[UIAlertView alloc]initWithTitle:@"\n\n\n" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    
    UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectMake(25,17, 100, 30)];
    lbl1.text=@"User Name";
    
    UILabel *lbl2 = [[UILabel alloc]initWithFrame:CGRectMake(25, 60, 80, 30)];
    lbl2.text = @"Password";
    
    UITextField *username=[[UITextField alloc]initWithFrame:CGRectMake(130, 17, 130, 30)];
    UITextField *password=[[UITextField alloc]initWithFrame:CGRectMake(130, 60, 130, 30)];
    
    lbl1.textColor = [UIColor whiteColor];
    lbl2.textColor = [UIColor whiteColor];
    
    [lbl1 setBackgroundColor:[UIColor clearColor]];
    [lbl2 setBackgroundColor:[UIColor clearColor]];
    
    username.borderStyle = UITextBorderStyleRoundedRect;
    password.borderStyle = UITextBorderStyleRoundedRect;
    
    [alt addSubview:lbl1];
    [alt addSubview:lbl2];
    [alt addSubview:username];
    [alt addSubview:password];
    
    [alt show];
    

提交回复
热议问题