UIAlertController

 1、UIAlertControllerStyleActionSheet样式code

- (void)actionSheet {

    UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *showAllInfoAction = [UIAlertAction actionWithTitle:@"查看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];
    UIAlertAction *pickAction = [UIAlertAction actionWithTitle:@"评论" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

    }];

    [actionSheetController addAction:cancelAction];
    [actionSheetController addAction:commentAction];
    [actionSheetController addAction:showAllInfoAction];

    [self presentViewController:actionSheetController animated:YES completion:nil];
}

 

2、UIAlertControllerStyleAlert样式it

UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *showAllInfoAction = [UIAlertAction actionWithTitle:@"查看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];
    UIAlertAction *commentAction = [UIAlertAction actionWithTitle:@"评论" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    }];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

    }];

    [actionSheetController addAction:cancelAction];
    [actionSheetController addAction:commentAction];
    [actionSheetController addAction:showAllInfoAction];

    [self presentViewController:actionSheetController animated:YES completion:nil];

效果图:io

详情请查看简书收藏的文章class

相关文章
相关标签/搜索