Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS11 无法获取_titleView #70

Open
ghost opened this issue Sep 4, 2017 · 7 comments
Open

iOS11 无法获取_titleView #70

ghost opened this issue Sep 4, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2017

  • (void)lt_setTitleAlpha:(CGFloat)alpha {

    if (@available(iOS 11.0, *)) {

    } else {

      UIView *titleView = [self valueForKey:@"_titleView"];
      titleView.alpha = alpha;
    

    }
    }

@MrWilsonXu
Copy link

同样 [self valueForKey:@"_leftViews"] 会crash

@KinmoCode
Copy link

想问一下这个问题你们解决了吗?

@KinmoCode
Copy link

解决的话可以贴一下解决方式么

@xq931014
Copy link

xq931014 commented Sep 27, 2017

[self valueForKey:@"_leftViews"] 会crash的我的解决办法
会crash的原因是,iOS11 UINavigationBar 没有_leftViews,_rightViews,_titleView这些key
解决办法:通过代码找到leftButton 、rightButton和titleView,然后改变他们的透明度
tip:我们项目中没有用到titleView,所以我找到了leftButton和rightButton,至于titleView在哪,需要自己慢慢去发现
//如果是iOS 11
if (@available(iOS 11, *))
{
[[self subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {

        if ([obj isKindOfClass:NSClassFromString(@"_UINavigationBarContentView")]) {
            
            for (UIView *view in [obj subviews])
            {
                view.alpha = alpha;
            }
        }
    }];
}
else
{
    [[self valueForKey:@"_leftViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
        view.alpha = alpha;
    }];
    
    [[self valueForKey:@"_rightViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
        view.alpha = alpha;
    }];
    
    UIView *titleView = [self valueForKey:@"_titleView"];
    titleView.alpha = alpha;
}

@YueHooo
Copy link

YueHooo commented Oct 13, 2017

@xq931014 你好,不知道这个问题,你最后找到titleView了吗,还是说你从其他途径解决此问题了,如有方法,谢谢解惑.

@KinmoCode
Copy link

emmm,因为这个第三方很久没维护了,所以我用了另外一个:https://github.com/wangrui460/WRNavigationBar,不过个人使用后感觉侵入性还是有点强,你可以参考一下

@YueHooo
Copy link

YueHooo commented Oct 16, 2017

@LoveJuly 好的,谢谢推荐.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants