博客> ios8以后使用操作表/警示框
ios8以后使用操作表/警示框
2018-12-13 11:58 评论:1 阅读:773 沐晨_梦雪

ios8以后使用操作表 UIAlertController alertController = [UIAlertController alertControllerWithTitle: nil message: nil preferredStyle:UIAlertControllerStyleActionSheet]; //添加Button [alertController addAction: [UIAlertAction actionWithTitle: @"拍照" style: UIAlertActionStyleDefault handler:^(UIAlertAction action) { //处理点击拍照 }]]; [alertController addAction: [UIAlertAction actionWithTitle: @"从相册选取" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action){ //处理点击从相册选取 }]]; [alertController addAction: [UIAlertAction actionWithTitle: @"取消" style: UIAlertActionStyleCancel handler:nil]];

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

_ios8以后使用警示框*_ 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];
收藏
1
sina weixin mail 回到顶部