添加弹窗
This commit is contained in:
@@ -20,10 +20,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 配置标题与是否显示垃圾桶
|
||||
- (void)configWithTitle:(NSString *)title showTrash:(BOOL)showTrash;
|
||||
|
||||
/// 清除按钮点击回调
|
||||
/// 清除按钮点击回调(用户在弹窗中点击“确定”后触发)
|
||||
@property (nonatomic, copy) void(^onTapTrash)(void);
|
||||
|
||||
/// “确定”按钮颜色(默认黑色)
|
||||
@property (nonatomic, strong, nullable) UIColor *confirmColor;
|
||||
/// “取消”按钮颜色(默认黑色)
|
||||
@property (nonatomic, strong, nullable) UIColor *cancelColor;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
//
|
||||
|
||||
#import "KBSearchSectionHeader.h"
|
||||
#import "KBAlert.h"
|
||||
|
||||
@interface KBSearchSectionHeader ()
|
||||
@property (nonatomic, strong, readwrite) UILabel *titleLabel;
|
||||
@@ -15,6 +16,8 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setupUI];
|
||||
_confirmColor = [UIColor redColor];
|
||||
_cancelColor = [UIColor blackColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -39,7 +42,19 @@
|
||||
}
|
||||
|
||||
- (void)tapTrash {
|
||||
if (self.onTapTrash) { self.onTapTrash(); }
|
||||
// 弹出确认框:是否删除所有历史记录
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[KBAlert confirmTitle:@"清空历史"
|
||||
message:@"是否删除所有历史记录?"
|
||||
ok:@"确定"
|
||||
cancel:@"取消"
|
||||
okColor:weakSelf.confirmColor
|
||||
cancelColor:weakSelf.cancelColor
|
||||
completion:^(BOOL ok) {
|
||||
if (ok && weakSelf.onTapTrash) {
|
||||
weakSelf.onTapTrash();
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)configWithTitle:(NSString *)title showTrash:(BOOL)showTrash {
|
||||
@@ -69,4 +84,3 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user