Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.05k stars 1.37k forks source link

开启 AutomaticCustomNavigationBarTransitionStyle 的情况下,从界面 B pop 回界面 A 的过程,如果 A 的导航栏效果与全局默认效果不同,则在 pop 过程中 A 的导航栏样式错误 #1432

Closed fanyuecheng closed 1 year ago

fanyuecheng commented 1 year ago

Bug 表现 _QMUITransitionNavigationBar 样式错误

截图 Aug-12-2022 14-37-36

如何重现 QMUIDemo “优化导航栏在转场时的样式 ” 多次点击不同样式跳转后,返回会发现 从 “默认”到“深色”的过程中,“深色”vc的假导航栏是“默认”的蓝色,pop完成后,“深色”vc的假导航栏移除,显示了原本的灰色。

预期的表现 正常情况下,深色vc的假导航栏应该是灰色

其他信息

fanyuecheng commented 1 year ago

好像是pop时, addTransitionNavigationBarAndBindNavigationBar: -> [self.view addSubview:customBar] -> [UINavigationBar _didMoveFromWindow:toWindow:] -> setBackgroundImage:forBarPosition:barMetrics:UINavigationBar+QMUI 中重写了 setBackgroundImage:forBarPosition:barMetrics: 并在其中为 appearance.backgroundImage 赋值,同时将该 appearance 赋值给navigationBar。 这个image一直是[UIImage qmui_imageWithThemeManagerName:QMUIThemeManagerNameDefault provider:provider] 就在这时候,appearance错误的赋值给了_QMUITransitionNavigationBar。 但是正在消失的vc好像就不会触发这些操作,仅正在出现的vc才会有。 同时不知道

copyStylesToBar.standardAppearance = self.standardAppearance; 
copyStylesToBar.scrollEdgeAppearance = self.scrollEdgeAppearance;

为什么没起作用

我在重写的这个方法syncAppearance前加了判断,不知是否有问题。

if ([selfObject isKindOfClass:NSClassFromString(@"_QMUITransitionNavigationBar")]) {  
     return;  
}  
syncAppearance(selfObject, ^void(UINavigationBarAppearance *appearance) {  
     appearance.backgroundImage = image;  
});
MoLice commented 1 year ago

已发布 4.5.1 修复该问题。