關(guān)于UIAlertController的基本使用:
UIAlertControlle 彈出樣式:
UIAlertControllerStyleAlert 在屏幕中間
UIAlertControllerStyleActionSheet 在屏幕底部
<pre>
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"標(biāo)題" message:@"內(nèi)容" preferredStyle:UIAlertControllerStyleAlert];
<code>UIAlertAction 按鈕樣式:
UIAlertActionStyleDefault,
UIAlertActionStyleCancel,
UIAlertActionStyleDestructive
<pre>UIAlertAction **default = [UIAlertAction actionWithTitle:@"Default" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) { NSLog(@"回調(diào)"); }];
UIAlertAction *Destructive = [UIAlertAction actionWithTitle:@"Destructive" style:UIAlertActionStyleDestructive handler:nil];
UIAlertAction *Cancel = [UIAlertAction actionWithTitle:@"Destructive" style:UIAlertActionStyleCancel handler:nil]; <code>
-
添加UIAlertAction:
<pre>
[alert addAction:Default];
[alert addAction:Destructive];
[alert addAction:Cancel];// 添加TextField
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
}];
// 顯示
[self presentViewController:alert animated:YES completion:nil];
<code>