添加弹窗
This commit is contained in:
@@ -119,6 +119,22 @@ static __weak UIViewController *sDefaultPresenter = nil; // 可选外部指定
|
||||
ok:(NSString *)okTitle
|
||||
cancel:(NSString *)cancelTitle
|
||||
completion:(KBAlertBoolHandler)completion {
|
||||
[self confirmTitle:title message:message ok:okTitle cancel:cancelTitle okColor:nil cancelColor:nil completion:completion];
|
||||
}
|
||||
|
||||
// KVC 方式设置 action 文字颜色(非公开 API,做保护)
|
||||
static inline void KBSetActionTitleColor(UIAlertAction *action, UIColor *color) {
|
||||
if (!color || !action) return;
|
||||
@try { [action setValue:color forKey:@"titleTextColor"]; } @catch (__unused NSException *e) {}
|
||||
}
|
||||
|
||||
+ (void)confirmTitle:(NSString *)title
|
||||
message:(NSString *)message
|
||||
ok:(NSString *)okTitle
|
||||
cancel:(NSString *)cancelTitle
|
||||
okColor:(UIColor *)okColor
|
||||
cancelColor:(UIColor *)cancelColor
|
||||
completion:(KBAlertBoolHandler)completion {
|
||||
[self enqueuePresent:^{
|
||||
UIViewController *vc = [self presentingVC];
|
||||
if (!vc) { [self _markFinishedAndContinue]; return; }
|
||||
@@ -138,6 +154,10 @@ static __weak UIViewController *sDefaultPresenter = nil; // 可选外部指定
|
||||
[wac dismissViewControllerAnimated:YES completion:nil];
|
||||
[KBAlert _markFinishedAndContinue];
|
||||
}];
|
||||
// 自定义颜色
|
||||
KBSetActionTitleColor(okAct, okColor);
|
||||
KBSetActionTitleColor(cancelAct, cancelColor);
|
||||
|
||||
[ac addAction:cancelAct];
|
||||
[ac addAction:okAct];
|
||||
[vc presentViewController:ac animated:YES completion:nil];
|
||||
@@ -221,4 +241,3 @@ static __weak UIViewController *sDefaultPresenter = nil; // 可选外部指定
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user