UIAlertController使用

    //1创建弹框控制器
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"亲,确定要滚吗?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    //2.1添加确定事件
    UIAlertAction *sureBtn = [UIAlertAction actionWithTitle:info style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        // 回到登录界面
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [alertVc addAction:sureBtn];
    //2.2添加取消事件
    UIAlertAction *cancelBtn = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"---点击了取消按钮");
    }];
    [alertVc addAction:cancelBtn];
    //3展示控制器
    [self presentViewController:alertVc animated:YES completion:nil];
原文地址:https://www.cnblogs.com/dzq1991/p/6251041.html