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

iOS18适配,导航栏透底问题已修复 #188

Open
xygkevin opened this issue Sep 18, 2024 · 22 comments
Open

iOS18适配,导航栏透底问题已修复 #188

xygkevin opened this issue Sep 18, 2024 · 22 comments

Comments

@xygkevin
Copy link
Contributor

No description provided.

@cuizhiyuan
Copy link

@listenzz 麻烦尽快适配一下iOS18

@ctl0809
Copy link

ctl0809 commented Sep 19, 2024

iOS18 设置hbd_barAlpha=0.0 的页面 push 到下个页面会出现导航栏

Uploading ღ Monster .tu lin 2024-09-09 14.46.24.mp4…

透底情况,麻烦尽快适配 18 哦

@xygkevin
Copy link
Contributor Author

BUG已定位并修复
@cuizhiyuan @ctl0809 @listenzz

问题定位:

UIView *back = self.navigationBar.subviews[0];

其本意应该是或取_UIBarBackground背景图层对象,但是更新iOS18之后,当我们使用导航控制进行push或者pop的时候会执行以下方法:

1、<_UIBarBackground: 0x10a2bf700> removeFromSuperview
2、UINavigationBar会执行-[insertSubview:<_UIBarBackground: 0x10a2bf700> atIndex:0]

问题方法正好在1和2之前执行,导致获取不到正确的_UIBarBackground对象,而是另外一个_UIPointerInteractionAssistantEffectContainerView对象,frame={0, 0, 0, 0};

问题截图:
image

解决办法:
image

@xygkevin xygkevin changed the title iOS18需要适配 iOS18适配,导航栏透底问题已修复 Sep 19, 2024
@ctl0809
Copy link

ctl0809 commented Sep 19, 2024

后面会更新版本吗?

@xygkevin
Copy link
Contributor Author

不晓得作者是否还会继续维护,但我决定放弃使用它了,其实还有很多问题[捂脸],每次大更新都提心吊胆的。

@cuizhiyuan
Copy link

有好的替代框架吗?没有的话,我都改回原生算了

@ctl0809
Copy link

ctl0809 commented Sep 19, 2024

同问,有好的替代框架吗?

@xygkevin
Copy link
Contributor Author

木有

@178408714
Copy link

改了 问题依然存在 😶

@xygkevin
Copy link
Contributor Author

可以试试自己计算frame @178408714

@178408714
Copy link

改成了 😄
[self.navigationBar setNeedsLayout];
[self.navigationBar layoutIfNeeded];

只能先这样了

Vincentzzg pushed a commit to Vincentzzg/HBDNavigationBar that referenced this issue Sep 20, 2024
@Serakaterina
Copy link

Serakaterina commented Sep 20, 2024

image
最好是在这个地方进行判断,如果发现frame为0,自己配置为状态栏的frame(如图中frame代码只是为了做测试使用)。
使用以下两句代码是有问题的:
[self.navigationBar setNeedsLayout];
[self.navigationBar layoutIfNeeded];
具体表现为:当A页面导航栏透明,黑色状态栏,B页面白色navigationTitle时,白色状态栏时,手势侧滑过程中,就会把navigationTitle颜色改为黑色了。

listenzz added a commit that referenced this issue Sep 21, 2024
@todayismancheng
Copy link

todayismancheng commented Sep 24, 2024

在ios18上,当前hbd_barAlpha = 0 push的时候下一个导航栏显示不正常
playGestureRecognizer 2.zip

@todayismancheng
Copy link

@listenzz

@xygkevin
Copy link
Contributor Author

暂且这么修改吧

- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = 0;
    CGFloat h = 0;
    if (@available(iOS 13.0, *)) {
        UIWindowScene *windowScene = [UIApplication sharedApplication].connectedScenes.allObjects.firstObject;
        w = CGRectGetWidth(windowScene.statusBarManager.statusBarFrame);
        h = 44.0 + CGRectGetHeight(windowScene.statusBarManager.statusBarFrame);
    } else {
        w = CGRectGetWidth(UIApplication.sharedApplication.statusBarFrame);
        h = CGRectGetHeight(UIApplication.sharedApplication.statusBarFrame) + 44.0;
    }
    y = -h;
    return CGRectMake(x, y, w, h);
}

@listenzz
Copy link
Owner

暂且这么修改吧

- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = 0;
    CGFloat h = 0;
    if (@available(iOS 13.0, *)) {
        UIWindowScene *windowScene = [UIApplication sharedApplication].connectedScenes.allObjects.firstObject;
        w = CGRectGetWidth(windowScene.statusBarManager.statusBarFrame);
        h = 44.0 + CGRectGetHeight(windowScene.statusBarManager.statusBarFrame);
    } else {
        w = CGRectGetWidth(UIApplication.sharedApplication.statusBarFrame);
        h = CGRectGetHeight(UIApplication.sharedApplication.statusBarFrame) + 44.0;
    }
    y = -h;
    return CGRectMake(x, y, w, h);
}

@todayismancheng 试下这个方案

@todayismancheng
Copy link

暂且这么修改吧

- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = 0;
    CGFloat h = 0;
    if (@available(iOS 13.0, *)) {
        UIWindowScene *windowScene = [UIApplication sharedApplication].connectedScenes.allObjects.firstObject;
        w = CGRectGetWidth(windowScene.statusBarManager.statusBarFrame);
        h = 44.0 + CGRectGetHeight(windowScene.statusBarManager.statusBarFrame);
    } else {
        w = CGRectGetWidth(UIApplication.sharedApplication.statusBarFrame);
        h = CGRectGetHeight(UIApplication.sharedApplication.statusBarFrame) + 44.0;
    }
    y = -h;
    return CGRectMake(x, y, w, h);
}

@todayismancheng 试下这个方案

现在导航栏能正常显示了。 还有个问题是 导航栏的push pop 的时候 里面的内容会跳一下

@xygkevin
Copy link
Contributor Author

@todayismancheng 我这里没发现闪动的问题,可以发个DEMO,录个屏看下问题原因

@todayismancheng
Copy link

todayismancheng commented Sep 26, 2024

ScreenRecording_09-26-2024.11-20-56_1.MP4

我在demo上没复现,但是在app上是这个样子
@xygkevin

@xygkevin
Copy link
Contributor Author

嗯嗯,那目前这个只能自己先慢慢排查问题原因了。

@htyo
Copy link

htyo commented Sep 27, 2024

暂且这么修改吧

- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = 0;
    CGFloat h = 0;
    if (@available(iOS 13.0, *)) {
        UIWindowScene *windowScene = [UIApplication sharedApplication].connectedScenes.allObjects.firstObject;
        w = CGRectGetWidth(windowScene.statusBarManager.statusBarFrame);
        h = 44.0 + CGRectGetHeight(windowScene.statusBarManager.statusBarFrame);
    } else {
        w = CGRectGetWidth(UIApplication.sharedApplication.statusBarFrame);
        h = CGRectGetHeight(UIApplication.sharedApplication.statusBarFrame) + 44.0;
    }
    y = -h;
    return CGRectMake(x, y, w, h);
}

@todayismancheng 试下这个方案

对我有用

listenzz added a commit that referenced this issue Oct 18, 2024
@xygkevin
Copy link
Contributor Author

@listenzz @ctl0809 @cuizhiyuan @todayismancheng 最终修复版本可以试下这个PR

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

8 participants