Skip to content

Commit 8b9dbaf

Browse files
committed
改改改
1 parent 4d6b359 commit 8b9dbaf

4 files changed

Lines changed: 42 additions & 9 deletions

File tree

Coding_iOS/Vendor/PopMenu/MenuButton.m

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ - (instancetype)initWithFrame:(CGRect)frame menuItem:(MenuItem *)menuItem {
4040
[self addSubview:self.iconImageView];
4141

4242
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.iconImageView.frame), CGRectGetWidth(self.bounds), 35)];
43-
self.titleLabel.textColor = [UIColor whiteColor];
43+
self.titleLabel.textColor = [UIColor blackColor];
4444
self.titleLabel.backgroundColor = [UIColor clearColor];
4545
self.titleLabel.font = [UIFont systemFontOfSize:14];
4646
self.titleLabel.textAlignment = NSTextAlignmentCenter;
@@ -54,6 +54,10 @@ - (instancetype)initWithFrame:(CGRect)frame menuItem:(MenuItem *)menuItem {
5454
}
5555

5656
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
57+
[self popBegan];
58+
}
59+
60+
- (void)popBegan{
5761
// 播放缩放动画
5862
POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation];
5963
scaleAnimation.springBounciness = 20; // value between 0-20
@@ -81,13 +85,29 @@ - (void)disMissCompleted:(void(^)(BOOL finished))completed {
8185
[self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"];
8286
}
8387

88+
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
89+
UITouch *curTouch = [touches anyObject];
90+
if (CGRectContainsPoint(self.bounds, [curTouch locationInView:self]) &&
91+
!CGRectContainsPoint(self.bounds, [curTouch previousLocationInView:self])) {
92+
[self popBegan];
93+
}else if (!CGRectContainsPoint(self.bounds, [curTouch locationInView:self]) &&
94+
CGRectContainsPoint(self.bounds, [curTouch previousLocationInView:self])){
95+
[self disMissCompleted:NULL];
96+
}
97+
}
98+
8499
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
85-
// 回调
86-
[self disMissCompleted:^(BOOL finished) {
87-
if (self.didSelctedItemCompleted) {
88-
self.didSelctedItemCompleted(self.menuItem);
89-
}
90-
}];
100+
UITouch *curTouch = [touches anyObject];
101+
if (CGRectContainsPoint(self.bounds, [curTouch locationInView:self])) {
102+
// 回调
103+
[self disMissCompleted:^(BOOL finished) {
104+
if (self.didSelctedItemCompleted) {
105+
self.didSelctedItemCompleted(self.menuItem);
106+
}
107+
}];
108+
}else{
109+
[self disMissCompleted:NULL];
110+
}
91111
}
92112

93113
@end

Coding_iOS/Vendor/PopMenu/PopMenu.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ - (void)setup {
5757

5858
typeof(self) __weak weakSelf = self;
5959
_realTimeBlur = [[XHRealTimeBlur alloc] initWithFrame:self.bounds];
60+
_realTimeBlur.blurStyle = XHBlurStyleTranslucentWhite;
6061
_realTimeBlur.showDuration = 0.3;
6162
_realTimeBlur.disMissDuration = 0.5;
6263
_realTimeBlur.willShowBlurViewcomplted = ^(void) {

Coding_iOS/Vendor/XHRealTimeBlur/XHRealTimeBlur.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ static NSString * const XHRealTimeDidDismissBlurViewBlcokKey = @"XHRealTimeDidDi
2727
typedef NS_ENUM(NSInteger, XHBlurStyle) {
2828
// 垂直梯度背景从黑色到半透明的。
2929
XHBlurStyleBlackGradient = 0,
30-
// 类似UIToolbar的半透明背景
30+
// 类似UIToolbar的半透明背景(黑)
3131
XHBlurStyleTranslucent,
32+
// 类似UIToolbar的半透明背景(白)
33+
XHBlurStyleTranslucentWhite,
3234
// 黑色半透明背景
3335
XHBlurStyleBlackTranslucent,
3436
// 纯白色

Coding_iOS/Vendor/XHRealTimeBlur/XHRealTimeBlur.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
3636
@interface XHRealTimeBlur ()
3737

3838
@property (nonatomic, strong) XHGradientView *gradientBackgroundView;
39-
@property (nonatomic, strong) UIToolbar *blurBackgroundView;
39+
@property (nonatomic, strong) UIToolbar *blurBackgroundView, *blurWhiteBackgroundView;
4040
@property (nonatomic, strong) UIView *blackTranslucentBackgroundView;
4141
@property (nonatomic, strong) UIView *whiteBackgroundView;
4242

@@ -132,6 +132,14 @@ - (UIToolbar *)blurBackgroundView {
132132
return _blurBackgroundView;
133133
}
134134

135+
- (UIToolbar *)blurWhiteBackgroundView {
136+
if (!_blurWhiteBackgroundView) {
137+
_blurWhiteBackgroundView = [[UIToolbar alloc] initWithFrame:self.bounds];
138+
[_blurWhiteBackgroundView setBarStyle:UIBarStyleDefault];
139+
}
140+
return _blurWhiteBackgroundView;
141+
}
142+
135143
- (UIView *)blackTranslucentBackgroundView {
136144
if (!_blackTranslucentBackgroundView) {
137145
_blackTranslucentBackgroundView = [[UIView alloc] initWithFrame:self.bounds];
@@ -156,6 +164,8 @@ - (UIView *)backgroundView {
156164
break;
157165
case XHBlurStyleTranslucent:
158166
return self.blurBackgroundView;
167+
case XHBlurStyleTranslucentWhite:
168+
return self.blurWhiteBackgroundView;
159169
case XHBlurStyleBlackTranslucent:
160170
return self.blackTranslucentBackgroundView;
161171
break;

0 commit comments

Comments
 (0)