//底部弹窗
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];//StyleActionSheet是底部弹窗
[alert addAction:[UIAlertAction actionWithTitle:@"第一个" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//点击第一个之后所做的事情
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"第二个" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
}]];//Destructive状态的标题是红色 表示要做一些危险操作
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];//cancel状态在UI提现上是跟上边两个状态分开的
[self presentViewController:alert animated:YES completion:nil];
//中间弹窗
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请输入账号" message:nil preferredStyle:UIAlertControllerStyleAlert];//StyleAlert是中间弹窗
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"请输入账号";//占位文字
}];//添加文本输入框
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]];//cancel状态在UI提现上是跟上边两个状态分开的
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//点击第一个之后所做的事情
NSString *zhanghaoStr = [alert.textFields[0] text];//拿到第一个输入框的文字
NSLog(@"---------%@",zhanghaoStr);
}]];
[self presentViewController:alert animated:YES completion:nil];
//******通过利用kvc对字体颜色进行修改 *******//
UIAlertAction *alertAct = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alertAct setValue:[UIColor grayColor] forKey:@"_titleTextColor"];