[toc]

使用

参考文章

UIAlertControllerStyleActionSheet样式

代码示例

// UIAlertControllerStyleActionSheet样式
- (void)setupAlertController {
    self.alertController = [UIAlertController alertControllerWithTitle:@"操作demo"
                                                               message:nil
                                                        preferredStyle:UIAlertControllerStyleActionSheet];
    [self setupTransitionActionForAlertController:self.alertController];
    [self setupCancelActionForAlertController:self.alertController];
}

// 默认样式action
- (void)setupTransitionActionForAlertController:(UIAlertController *)alertController {
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"转场进入下一个页面"
                                                     style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction * _Nonnull action) {
        [self openNextVCWithNotNewNavVC];
    }];
    [alertController addAction:action];
}

// 取消样式action
- (void)setupCancelActionForAlertController:(UIAlertController *)alertController {
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        // 什么也不做
    }];
    [alertController addAction:cancelAction];
}

效果示例

03-05 23:51