This commit is contained in:
2025-12-03 18:02:20 +08:00
parent 4deccb76dc
commit a5ff2ce51b
8 changed files with 23 additions and 0 deletions

View File

@@ -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

View File

@@ -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