iOS UIAlertController实现弹窗输入账号密码

UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"登陆"
                                                                              message: @"输入用户名密码"
                                                                       preferredStyle:UIAlertControllerStyleAlert];
    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.placeholder = @"name";
        textField.textColor = [UIColor blueColor];
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        textField.borderStyle = UITextBorderStyleRoundedRect;
    }];
    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.placeholder = @"password";
        textField.textColor = [UIColor blueColor];
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        textField.borderStyle = UITextBorderStyleRoundedRect;
        textField.secureTextEntry = YES;
    }];
    [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSArray * textfields = alertController.textFields;
        UITextField * namefield = textfields[0];
        UITextField * passwordfiled = textfields[1];
        NSLog(@"%@:%@",namefield.text,passwordfiled.text);

    }]];
    [self presentViewController:alertController animated:YES completion:nil];

阅读更多
个人分类: iOS 开发
上一篇iOS 调取本地地图以及三方地图
下一篇iOS 长按图片保存本地
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭