Skip to content

Commit

Permalink
QMUISearchController 增加 hidesNavigationBarDuringPresentation 接口用于控制进入…
Browse files Browse the repository at this point in the history
…搜索状态时要不要升起到 navigationBar 上
  • Loading branch information
MoLice committed Mar 24, 2017
1 parent 870f629 commit e648b03
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions QMUIKit/UIKitExtensions/QMUISearchController.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@
* @param animated 是否要以动画的形式展示状态切换
*/
- (void)setActive:(BOOL)active animated:(BOOL)animated;

/// 进入搜索状态时是否要把原界面的 navigationBar 推走,默认为 YES,仅在 iOS 8 及以后有效
@property(nonatomic, assign) BOOL hidesNavigationBarDuringPresentation;
@end
23 changes: 19 additions & 4 deletions QMUIKit/UIKitExtensions/QMUISearchController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ - (void)initTableView {
@interface QMUISearchDisplayController : UISearchDisplayController

@property(nonatomic, strong) UIView *customDimmingView;
@property(nonatomic, copy) void (^dimmingViewVisibleChangedBlock)(BOOL visible);
@end

@implementation QMUISearchDisplayController
Expand Down Expand Up @@ -85,9 +84,6 @@ - (UIColor *)_dimmingViewColor {
if (self.customDimmingView.superview != defaultDimmingView) {
[defaultDimmingView addSubview:self.customDimmingView];
}
if (self.dimmingViewVisibleChangedBlock) {
self.dimmingViewVisibleChangedBlock(self.isActive);
}
}
}

Expand Down Expand Up @@ -187,6 +183,8 @@ - (instancetype)initWithContentsViewController:(UIViewController *)viewControlle
self.searchDisplayController = [[QMUISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:viewController];
self.searchDisplayController.delegate = self;
}

self.hidesNavigationBarDuringPresentation = YES;
}
return self;
}
Expand Down Expand Up @@ -256,6 +254,23 @@ - (void)setLaunchView:(UIView *)dimmingView {
}
}

- (BOOL)hidesNavigationBarDuringPresentation {
if (self.searchController) {
return self.searchController.hidesNavigationBarDuringPresentation;
} else {
NSLog(@"%s 仅支持 iOS 8 及以上版本", __func__);
return YES;
}
}

- (void)setHidesNavigationBarDuringPresentation:(BOOL)hidesNavigationBarDuringPresentation {
if (self.searchController) {
self.searchController.hidesNavigationBarDuringPresentation = hidesNavigationBarDuringPresentation;
} else {
NSLog(@"%s 仅支持 iOS 8 及以上版本", __func__);
}
}

#pragma mark - QMUIEmptyView

- (void)showEmptyView {
Expand Down

0 comments on commit e648b03

Please sign in to comment.