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

相關文章
相關標籤/搜索