一.中间显示
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"提示" message:@"有事情吗" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *act1 = [UIAlertAction actionWithTitle:@"有" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击了有事情");
}];
UIAlertAction *act2 = [UIAlertAction actionWithTitle:@"没有" style: UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击了没有事情");
}];
[controller addAction:act1];
[controller addAction:act2];
[self presentViewController:controller animated:YES completion:nil];
二.底部显示
UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"警告" message:@"有事情吗你" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *act1=[UIAlertAction actionWithTitle:@"有" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"有事情的");
}];
UIAlertAction *act2=[UIAlertAction actionWithTitle:@"咩有" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"没有事情的");
}];
[controller addAction:act1];
[controller addAction:act2];
[self presentViewController:controller animated:YES completion:^{
}];