您的位置:首页 > 产品设计 > UI/UE

UIAlertController

2015-12-30 11:02 459 查看
 UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:nilmessage:title
preferredStyle:UIAlertControllerStyleAlert];

    

    /**设置 textField
的暗文 */
    [alertControlleraddTextFieldWithConfigurationHandler:^(UITextField *_Nonnull
textField) {
        textField.placeholder =@"密码";
        textField.secureTextEntry =YES;
    }];

    /**设置 alertController的按钮*/

    UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];

    UIAlertAction *okAction = [UIAlertActionactionWithTitle:@"确认"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction
*_Nonnull action) {
       UITextField *login = alertController.textFields.firstObject;
       if ([login.textisEqualToString:@"123"])
{
           NSLog(@"成功");
        }else{
           UIView * view = [[UIApplicationsharedApplication].windowslastObject];

            [selfshowMBProgressHUDWith:view
labelText:@"密码错误,请重试"andHidenTime:1];
        }
    }];

    

    /**设置 UIAlertAction的字体颜色 */
    [cancelActionsetValue:NAVCOLORforKey:@"_titleTextColor"];
    [okActionsetValue:NAVCOLORforKey:@"_titleTextColor"];

    
    [alertControlleraddAction:cancelAction];
    [alertControlleraddAction:okAction];

    

    /**弹出 alertController */

    [selfpresentViewController:alertController
animated:YEScompletion:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: