半屏的导航栏隐藏
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
#import "ThemeColor.h"
|
||||
#import "TTPopup.h"
|
||||
@interface XPRoomHalfWebView ()
|
||||
///容器
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///点击消失的view
|
||||
@property (nonatomic,strong) UIView * topView;
|
||||
/// 导航栏
|
||||
@@ -29,6 +31,10 @@
|
||||
@end
|
||||
|
||||
@implementation XPRoomHalfWebView
|
||||
- (void)dealloc {
|
||||
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
@@ -43,11 +49,22 @@
|
||||
- (void)initSubViews {
|
||||
|
||||
[self addSubview:self.topView];
|
||||
[self addSubview:self.toolView];
|
||||
[self addSubview:self.webVC.view];
|
||||
[self addSubview:self.stackView];
|
||||
|
||||
[self.stackView addArrangedSubview:self.toolView];
|
||||
[self.stackView addArrangedSubview:self.webVC.view];
|
||||
|
||||
[self.toolView addSubview:self.backButton];
|
||||
[self.toolView addSubview:self.titleLabel];
|
||||
@kWeakify(self);
|
||||
self.webVC.InitShowNavBlock = ^(BOOL show) {
|
||||
@kStrongify(self);
|
||||
self.toolView.hidden = YES;
|
||||
};
|
||||
|
||||
self.webVC.CloseWebViewBlock = ^(BOOL result) {
|
||||
[TTPopup dismiss];
|
||||
};
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
@@ -61,15 +78,16 @@
|
||||
make.bottom.mas_equalTo(self.toolView.mas_top);
|
||||
}];
|
||||
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.bottom.mas_equalTo(self);
|
||||
make.height.mas_equalTo(470);
|
||||
}];
|
||||
|
||||
CGFloat height = 430;
|
||||
[self.webVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self);
|
||||
make.bottom.mas_equalTo(0);
|
||||
make.height.mas_equalTo(height);
|
||||
}];
|
||||
[self.toolView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(self.webVC.view.mas_top);
|
||||
make.height.mas_equalTo(44);
|
||||
}];
|
||||
|
||||
@@ -101,6 +119,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStackView *)stackView {
|
||||
if (!_stackView) {
|
||||
_stackView = [[UIStackView alloc] init];
|
||||
_stackView.axis = UILayoutConstraintAxisVertical;
|
||||
_stackView.distribution = UIStackViewDistributionFill;
|
||||
_stackView.alignment = UIStackViewAlignmentFill;
|
||||
_stackView.spacing = 0;
|
||||
}
|
||||
return _stackView;
|
||||
}
|
||||
|
||||
- (UIView *)topView {
|
||||
if (!_topView) {
|
||||
_topView = [[UIView alloc] init];
|
||||
|
@@ -19,7 +19,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// URL加载完成回调,result:加载结果成功/失败,error:失败原因
|
||||
@property (nonatomic, copy) void (^urlLoadCompleted)(BOOL result, NSError * _Nullable error);
|
||||
|
||||
///是都隐藏导航栏 目前适用于半屏的情况下
|
||||
@property (nonatomic,copy) void (^InitShowNavBlock)(BOOL show);
|
||||
///关闭webView 目前适用于半屏的情况下
|
||||
@property (nonatomic,copy) void (^CloseWebViewBlock)(BOOL result);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -241,11 +241,19 @@ NSString * const kCloseWebView = @"closeWebView";
|
||||
}];
|
||||
} else if([message.name isEqualToString:kInitShowNav]) {
|
||||
if (((NSNumber *)message.body).intValue == 0) {
|
||||
if (self.InitShowNavBlock) {
|
||||
self.InitShowNavBlock(YES);
|
||||
return;
|
||||
}
|
||||
if (self.navigationController) {
|
||||
[self.navigationController setNavigationBarHidden:YES];
|
||||
}
|
||||
}
|
||||
} else if([message.name isEqualToString:kCloseWebView]) {
|
||||
if (self.CloseWebViewBlock) {
|
||||
self.CloseWebViewBlock(YES);
|
||||
return;
|
||||
}
|
||||
if (self.navigationController) {
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
Reference in New Issue
Block a user