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

QMUIThemeColor,设置UIView.backgroundColor = themeColor,切换日夜间模式可能不会生效的问题 #1597

Open
jiasongs opened this issue Nov 15, 2024 · 0 comments

Comments

@jiasongs
Copy link

jiasongs commented Nov 15, 2024

Bug 表现

图片

如上图所示,当前系统是日间模式下,第一次设置的日间模式color与第二次设置的日间模式color相同,且第二次日/夜间模式color相同的情况下,切换夜间模式后,第二次设置的color不会生效

Bug原因

图片

如上图所示,当设置CALayer.backgroundColor时会将存储的QMUIThemeColor还给CALayer,CALayer使用QMUIThemeColor.cgColor,通过UIView.backgroundColor = QMUIThemeColor也会去设置CALayer.backgroundColor,当「前后颜色相同」时,第二次并不会调用CALayer.backgroundColor,CALayer用的还是第一次设置的QMUIThemeColor,所以会造成上面的bug。

解决方案

图片 如上所示,将qcl_originalBackgroundColor赋值即可

另外,如下图所示,cgColor绑定QMUIThemeColor时应该用weak,上述表现也会引起QMUIThemeColor不能正确被释放

图片 图片

其他信息

  • 设备: all
  • iOS 版本: iOS 13及以上
  • Xcode 版本: Xcode 16.0
  • QMUI 版本: 4.8.0
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

1 participant