@@ -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
0 commit comments