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兼容问题 #189

Open
YanLingZhao995 opened this issue Sep 25, 2024 · 10 comments
Open

iOS18兼容问题 #189

YanLingZhao995 opened this issue Sep 25, 2024 · 10 comments

Comments

@YanLingZhao995
Copy link

字页面导航栏设置其他颜色,push后,导航栏高度会闪一下,已用最新版本

@Marcello168
Copy link

加一

@Marcello168
Copy link

iOS 17 也会闪一下

@wyggg
Copy link

wyggg commented Oct 14, 2024

iOS18下导航跳转时,在导航栏无透明度的时候,页面跳转的动画过程,背景部分会向下偏移一个导航的高度,动画结束后恢复正常

测试

将Demo中DemoViewController.m的- (UIViewController *)createDemoViewController方法改为固定传入一个无透明度的颜色
该问题便会出现

- (UIViewController *)createDemoViewController {
    DemoViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"demo"];

    vc.hbd_barShadowHidden = self.shadowHiddenSwitch.isOn;
    vc.hbd_barHidden = self.barHiddenSwitch.isOn;
    vc.hbd_barStyle = self.blackStyleSwitch.isOn ? UIBarStyleBlack : UIBarStyleDefault;
//    UIColor *color = @[
//            [UIColor colorWithRed:247 / 255.0 green:247 / 255.0 blue:247 / 255.0 alpha:0.8],
//            [UIColor colorWithRed:28 / 255.0 green:28 / 255.0 blue:28 / 255.0 alpha:0.729],
//            [UIColor.redColor colorWithAlphaComponent:0.7],
//            [UIColor.greenColor colorWithAlphaComponent:0.7],
//            [UIColor.blueColor colorWithAlphaComponent:0.8]
//    ][self.colorSegment.selectedSegmentIndex];

    vc.hbd_barTintColor = [UIColor redColor];
//    vc.hbd_barTintColor = color;
//    vc.hbd_barImage = [DemoViewController imageWithColor:color];
    return vc;
}
image

经排查,在iOS18下,HBDNavigationController中,fromFakeImageView和toFakeImageView的这两个临时视图位置无法正确计算

- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
    CGRect frame = CGRectMake(0, 0, self.navigationBar.frame.size.width, UIApplication.sharedApplication.statusBarFrame.size.height + self.navigationBar.frame.size.height);
    return frame;
}

解决

修改frame计算方法,可临时该问题
将HBDNavigationController的- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc修改为如下代码

- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
    CGFloat height = self.navigationBar.frame.size.height + self.navigationBar.frame.origin.y;
    if (vc.view.frame.size.height == self.view.frame.size.height) {
        return CGRectMake(0, 0, self.navigationBar.frame.size.width, height);
    }else{
        return CGRectMake(0, -height, self.navigationBar.frame.size.width, height);
    }
}

还是希望作者尽快更新

@TimorYang
Copy link

@wyggg

CGFloat fakeHeight = navigationHeight + statusBarHeight;
    if (@available(iOS 18.0, *)) {
        fakeHeight = fakeHeight + 3;
    }

fakeHeight = fakeHeight + 3;
这段代码没看懂,实际加进去后,返回过程中,会发现上一个页面的NavigationBar 比当前的高,移除这段代码,就没有问题了。
麻烦老哥解释下,谢谢。

@wyggg
Copy link

wyggg commented Oct 17, 2024

@wyggg
fakeHeight = fakeHeight + 3; 这段代码没看懂,实际加进去后,返回过程中,会发现上一个页面的NavigationBar 比当前的高,移除这段代码,就没有问题了。 麻烦老哥解释下,谢谢。

之前的计算方式存在问题,已更正

@TimorYang
Copy link

@wyggg 老哥,提个PR上来

@wyggg
Copy link

wyggg commented Oct 17, 2024

@wyggg 老哥,提个PR上来

👌🏻

listenzz added a commit that referenced this issue Oct 18, 2024
@TimorYang
Copy link

@listenzz 这个是不是可以close了

@xygkevin
Copy link
Contributor

@TimorYang @TimorYang @wyggg @YanLingZhao995 @listenzz 可以试下这个PRhttps://github.com//pull/191

@TimorYang
Copy link

@xygkevin

s.source           = { :git => 'https://github.com/listenzz/HBDNavigationBar.git', :tag => s.version.to_s }
s.source           = { :git => 'https://github.com/xygkevin/HBDNavigationBar.git', :tag => s.version.to_s }

你的PR,把项目地址都改掉了,而且增加了Protocol,改动相对较大,myDelete的命名有点太随意了。还有不少改动是不需要放到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

5 participants