listenzz / HBDNavigationBar

A custom UINavigationBar for smooth switching between various states, including bar style, bar tint color, background image, background alpha, bar hidden, title text attributes, tint color, shadow hidden...
MIT License
1.65k stars 215 forks source link

导航栏事件穿透拦截问题 #119

Closed devcxm closed 4 years ago

devcxm commented 4 years ago

因为我项目自定义XXNavigationBar继承HBDNavigationBar,然后HBDNavigationBar的事件传递判断用了以下字符串比较,这样进入不了相应的逻辑处理,所以建议作者用[view isKindOfClass:[HBDNavigationBar class]]替代字符串判断。

if (view && [viewName isEqualToString:@"HBDNavigationBar"]) {

NSArray *array = @[ @"UINavigationBarContentView", @"HBDNavigationBar" ];
if ([array containsObject:viewName]) {
devcxm commented 4 years ago

不好意思挖个坟,以下这块代码还是没有处理会不会出问题?

NSArray *array = @[ @"UINavigationBarContentView", @"HBDNavigationBar" ];
    if ([array containsObject:viewName]) {
        if (self.backgroundImageView.image) {
            if (self.backgroundImageView.alpha < 0.01) {
                return nil;
            }
        } else if (self.fakeView.alpha < 0.01) {
            return nil;
        }
    }
listenzz commented 4 years ago

@devcxm 我再看看