1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // BlockAlertController.m
- // MIT_Endorsement
- //
- // Created by 翟玉磊 on 2018/4/2.
- // Copyright © 2018年 翟玉磊. All rights reserved.
- //
- #import "BlockAlertController.h"
- @implementation BlockAlertController
- + (UIAlertController *)actionSheetWithTitle:(NSString *)title message:(NSString *)message actionTitles:(NSArray *)titles cancelTitle:(NSString *)cancelTitle clickAction:(void (^)(UIAlertAction *))completion
- {
- UIAlertController *al = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet];
-
- for (NSString *name in titles) {
- UIAlertAction *action = [UIAlertAction actionWithTitle:name style:UIAlertActionStyleDefault handler:completion];
-
- [al addAction:action];
- }
-
- if ([BaseMethod isNOTNull:cancelTitle]) {
- UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:completion];
-
- [al addAction:cancel];
- }
- return al;
- }
- + (UIAlertController *)alertWithTitle:(NSString *)title message:(NSString *)message cancelTitle:(nonnull NSString *)cancelTitle sureTitle:(NSString *)sureTitle clickAction:(void (^)(UIAlertAction *))completion
- {
- UIAlertController *al = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *action = [UIAlertAction actionWithTitle:sureTitle style:UIAlertActionStyleDefault handler:completion];
- [al addAction:action];
-
- if ([BaseMethod isNOTNull:cancelTitle]) {
- UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:completion];
-
- [al addAction:cancel];
- }
- return al;
- }
- + (UIAlertController *)alertWithTitle:(NSString *)title message:(NSString *)message cancelTitle:(NSString *)cancelTitle cancelTitleColor:(UIColor *)cancelTitleColor sureTitle:(NSString *)sureTitle sureTitleColor:(UIColor *)sureTitleColor clickAction:(void (^)(UIAlertAction *))completion {
- UIAlertController *al = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
-
- if ([BaseMethod isNOTNull:cancelTitle]) {
- UIAlertAction *cancel = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleDefault handler:completion];
- if (cancelTitleColor) {
- [cancel setValue:cancelTitleColor forKey:@"_titleTextColor"];
- }
- [al addAction:cancel];
- }
-
- UIAlertAction *action = [UIAlertAction actionWithTitle:sureTitle style:UIAlertActionStyleDefault handler:completion];
- if (sureTitleColor) {
- [action setValue:sureTitleColor forKey:@"_titleTextColor"];
- }
- [al addAction:action];
- return al;
- }
- @end
|