新增 Banner 手势优化实施总结文档,记录了在 RoomAnimationView 中对 banner 手势系统的优化过程,包括手势识别器的重新设计、区域划分逻辑、tap 手势处理逻辑及交互区域检查等。同时,优化了多个视图中的通知处理逻辑,确保手势事件的准确传递与处理,提升用户交互体验。

This commit is contained in:
edwinQQQ
2025-08-15 19:34:25 +08:00
parent 84e146277a
commit 3f97b0293e
11 changed files with 871 additions and 910 deletions

View File

@@ -88,20 +88,21 @@
break;
}
[banner addNotification];
[superView addSubview:banner];
@kWeakify(banner);
// 使 POP banner
[banner popEnterAnimation:^(BOOL finished) {
@kStrongify(banner);
[banner addNotification];
if (finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@kStrongify(banner);
[banner popLeaveAnimation:^(bool finished) {
if (banner.animationComplete) {
banner.animationComplete();
}
[banner removeNotification];
[banner removeFromSuperview];
}];
});
@@ -113,15 +114,37 @@
[self.svgaImageView stopAnimation];
}
- (void)handleSwipeNotification {
[self dismissBanner];
}
- (void)handleTapNotification:(NSNotification *)note {
NSValue *value = note.userInfo[@"point"];
CGPoint point = [value CGPointValue];
// banner
CGPoint screenPoint = [self convertPoint:point toView:nil];
// FunctionContainer
[[NSNotificationCenter defaultCenter] postNotificationName:@"BannerTapToFunctionContainer"
object:nil
userInfo:@{@"point": [NSValue valueWithCGPoint:screenPoint]}];
}
- (void)addNotification {
@kWeakify(self);
[[NSNotificationCenter defaultCenter] addObserverForName:@"SwipeOutBanner"
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * _Nonnull notification) {
@kStrongify(self);
[self dismissBanner];
}];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleSwipeNotification)
name:@"SwipeOutBanner"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleTapNotification:)
name:@"TapBanner"
object:nil];
}
- (void)removeNotification {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dismissBanner {
@@ -406,16 +429,16 @@
}
// ========== 穿 ==========
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (!self.userInteractionEnabled || self.hidden || self.alpha <= 0.01) {
return nil;
}
CGPoint goButtonPoint = [self.goButton convertPoint:point fromView:self];
if ([self.goButton pointInside:goButtonPoint withEvent:event]) {
return self.goButton;
}
// self
return self;
}
//- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
// if (!self.userInteractionEnabled || self.hidden || self.alpha <= 0.01) {
// return nil;
// }
// CGPoint goButtonPoint = [self.goButton convertPoint:point fromView:self];
// if ([self.goButton pointInside:goButtonPoint withEvent:event]) {
// return self.goButton;
// }
// // self
// return self;
//}
@end