1
This commit is contained in:
@@ -26,6 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 自定义导航栏右侧按钮(懒加载,默认 hidden = YES)。
|
||||
@property (nonatomic, strong, readonly) UIButton *kb_rightButton;
|
||||
|
||||
/// 在当前页面添加“点击空白处收起键盘”的手势。可在需要的 VC 的 viewDidLoad 中调用。
|
||||
- (void)kb_addTapToDismissKeyboard;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -191,6 +191,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Keyboard
|
||||
|
||||
/// 默认实现:在需要的页面调用该方法,为 view 添加点击手势收起键盘。
|
||||
- (void)kb_addTapToDismissKeyboard {
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
|
||||
action:@selector(kb_onTapBackgroundToDismissKeyboard)];
|
||||
tap.cancelsTouchesInView = NO; // 不影响按钮/列表等正常点击
|
||||
[self.view addGestureRecognizer:tap];
|
||||
}
|
||||
|
||||
- (void)kb_onTapBackgroundToDismissKeyboard {
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user