Skip to content

Commit

Permalink
fix #314
Browse files Browse the repository at this point in the history
  • Loading branch information
agiapp committed Jul 2, 2024
1 parent 165018d commit 3359f37
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
30 changes: 15 additions & 15 deletions BRPickerView/Base/BRBaseView.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@interface BRBaseView ()
// 蒙层视图
@property (nonatomic, strong) UIView *maskView;
@property (nonatomic, strong) UIView *maskBgView;
// 标题栏背景视图
@property (nonatomic, strong) UIView *titleBarView;
// 左边取消按钮
Expand All @@ -36,7 +36,7 @@ - (void)initUI {
self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

if (!self.pickerStyle.hiddenMaskView) {
[self addSubview:self.maskView];
[self addSubview:self.maskBgView];
}

[self addSubview:self.alertView];
Expand Down Expand Up @@ -104,17 +104,17 @@ - (void)layoutSubviews {
}

#pragma mark - 蒙层视图
- (UIView *)maskView {
if (!_maskView) {
_maskView = [[UIView alloc]initWithFrame:self.keyView.bounds];
_maskView.backgroundColor = self.pickerStyle.maskColor;
- (UIView *)maskBgView {
if (!_maskBgView) {
_maskBgView = [[UIView alloc]initWithFrame:self.keyView.bounds];
_maskBgView.backgroundColor = self.pickerStyle.maskColor;
// 设置子视图的大小随着父视图变化
_maskView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_maskView.userInteractionEnabled = YES;
UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapMaskView:)];
[_maskView addGestureRecognizer:myTap];
_maskBgView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_maskBgView.userInteractionEnabled = YES;
UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapMaskBgView:)];
[_maskBgView addGestureRecognizer:myTap];
}
return _maskView;
return _maskBgView;
}

#pragma mark - 弹框视图
Expand Down Expand Up @@ -234,7 +234,7 @@ - (UILabel *)titleLabel {
}

#pragma mark - 点击蒙层视图事件
- (void)didTapMaskView:(UITapGestureRecognizer *)sender {
- (void)didTapMaskBgView:(UITapGestureRecognizer *)sender {
[self removePickerFromView:nil];
if (self.cancelBlock) {
self.cancelBlock();
Expand Down Expand Up @@ -318,11 +318,11 @@ - (void)addPickerToView:(UIView *)view {
self.alertView.frame = rect;
// 弹出动画
if (!self.pickerStyle.hiddenMaskView) {
self.maskView.alpha = 0;
self.maskBgView.alpha = 0;
}
[UIView animateWithDuration:0.3f animations:^{
if (!self.pickerStyle.hiddenMaskView) {
self.maskView.alpha = 1;
self.maskBgView.alpha = 1;
}
CGFloat alertViewHeight = self.alertView.bounds.size.height;
CGRect rect = self.alertView.frame;
Expand All @@ -344,7 +344,7 @@ - (void)removePickerFromView:(UIView *)view {
rect.origin.y += alertViewHeight;
self.alertView.frame = rect;
if (!self.pickerStyle.hiddenMaskView) {
self.maskView.alpha = 0;
self.maskBgView.alpha = 0;
}
} completion:^(BOOL finished) {
[self removeFromSuperview];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @interface BRMutableDatePickerView ()<UIPickerViewDataSource, UIPickerViewDelega
BOOL _isAdjustSelectRow; // 设置minDate时,调整日期联动的选择(解决日期选择器联动不正确的问题)
}
// 蒙层视图
@property (nonatomic, strong) UIView *maskView;
@property (nonatomic, strong) UIView *maskBgView;
// 弹出背景视图
@property (nonatomic, strong) UIView *alertView;
// 标题栏背景视图
Expand Down Expand Up @@ -74,7 +74,7 @@ - (void)initUI {
// 设置子视图的宽度随着父视图变化
self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self addSubview:self.maskView];
[self addSubview:self.maskBgView];

[self addSubview:self.alertView];
[self.alertView addSubview:self.titleBarView];
Expand All @@ -85,17 +85,17 @@ - (void)initUI {
}

#pragma mark - 蒙层视图
- (UIView *)maskView {
if (!_maskView) {
_maskView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
_maskView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2f];
- (UIView *)maskBgView {
if (!_maskBgView) {
_maskBgView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
_maskBgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2f];
// 设置子视图的大小随着父视图变化
_maskView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_maskView.userInteractionEnabled = YES;
UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapMaskView:)];
[_maskView addGestureRecognizer:myTap];
_maskBgView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_maskBgView.userInteractionEnabled = YES;
UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTapMaskBgView:)];
[_maskBgView addGestureRecognizer:myTap];
}
return _maskView;
return _maskBgView;
}

#pragma mark - 弹框视图
Expand Down Expand Up @@ -276,7 +276,7 @@ - (UIPickerView *)pickerView {
}

#pragma mark - 点击蒙层视图事件
- (void)didTapMaskView:(UITapGestureRecognizer *)sender {
- (void)didTapMaskBgView:(UITapGestureRecognizer *)sender {
[self dismiss];
}

Expand Down Expand Up @@ -305,7 +305,7 @@ - (void)show {
rect.origin.y = self.bounds.size.height;
self.alertView.frame = rect;
// 弹出动画
self.maskView.alpha = 1;
self.maskBgView.alpha = 1;
[UIView animateWithDuration:0.3f animations:^{
CGRect rect = self.alertView.frame;
rect.origin.y -= kPickerViewHeight + kTitleBarViewHeight + BR_BOTTOM_MARGIN;
Expand All @@ -320,7 +320,7 @@ - (void)dismiss {
CGRect rect = self.alertView.frame;
rect.origin.y += kPickerViewHeight + kTitleBarViewHeight + BR_BOTTOM_MARGIN;
self.alertView.frame = rect;
self.maskView.alpha = 0;
self.maskBgView.alpha = 0;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
Expand Down

0 comments on commit 3359f37

Please sign in to comment.