------??? 帶有輸入框的提示框? ------
有時(shí)候 , 我們需要帶有輸入框的提示框, 如圖:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"請(qǐng)輸入個(gè)人信息" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
UITextField *userNameTextField = alertController.textFields.firstObject;
UITextField *passwordTextField = alertController.textFields.lastObject;
NSLog(@"用戶名 = %@,密碼 = %@",userNameTextField.text,passwordTextField.text);
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"請(qǐng)輸入用戶名";
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"請(qǐng)輸入密碼";
}];
[self presentViewController:alertController animated:true completion:nil];
------? 修改系統(tǒng)提示框的字號(hào)和顏色等屬性 ------

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"提示信息" preferredStyle:UIAlertControllerStyleAlert];
//修改標(biāo)題的內(nèi)容,字號(hào),顏色。使用的key值是“attributedTitle”
NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"提示"];
[hogan addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:40] range:NSMakeRange(0, [[hogan string] length])];
[hogan addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, [[hogan string] length])];
[alertController setValue:hogan forKey:@"attributedTitle"];
//修改按鈕的顏色,同上可以使用同樣的方法修改內(nèi)容,樣式
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Default" style:UIAlertActionStyleDefault handler:nil];
[defaultAction setValue:[UIColor grayColor] forKey:@"_titleTextColor"];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
[cancelAction setValue:[UIColor greenColor] forKey:@"_titleTextColor"];
[alertController addAction:defaultAction];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
------? 改變提示文字的顏色? ------
這個(gè)是系統(tǒng)自帶的,? 只是改變了提示框的展示樣式.
UIAlertActionStyleDestructive

//顯示彈出框列表選擇
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Title"
message:@"This is an Sheet."
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"取消"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
//響應(yīng)事件
NSLog(@"action = %@", action);
}];
UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:@"刪除"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
//響應(yīng)事件
NSLog(@"action = %@", action);
}];
UIAlertAction* saveAction = [UIAlertAction actionWithTitle:@"保存"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//響應(yīng)事件
NSLog(@"action = %@", action);
}];
[alert addAction:saveAction];
[alert addAction:cancelAction];
[alert addAction:deleteAction];
[self presentViewController:alert animated:YES completion:nil];