We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug 表现 颜色名称: B1 Light: 0xffffff Dark: 0x121212
B1
Light: 0xffffff
Dark: 0x121212
在BaseViewController viewDidLoad 中默认设置了 self.view.backgroundColor = B1 B页面不支持主题模式,所以在 viewDidLoad 中设置了self.view.backgroundColor = UIColorMake(0x12, 0x12, 0x12) 当主题模式设为跟随系统时, 在A页面后将系统dark mode开启, 然后push到B页面 进入B页面后颜色为0x121212正常, 此时将系统dark mode关闭后, B页面变成了0xffffff不正常
BaseViewController viewDidLoad
self.view.backgroundColor = B1
B
viewDidLoad
self.view.backgroundColor = UIColorMake(0x12, 0x12, 0x12)
A
dark mode
push
0x121212
0xffffff
通过调试发现一个颜色在多次调用CGColor时会出现内存地址一样的情况
CGColor
继续分析发现在UIColor+QMUITheme.m
UIColor+QMUITheme.m
- (CGColorRef)CGColor { CGColorRef colorRef = [UIColor colorWithCGColor:self.qmui_rawColor.CGColor].CGColor; [(__bridge id)(colorRef) qmui_bindObject:self forKey:QMUICGColorOriginalColorBindKey]; return colorRef; }
CALayer (QMUIThemeCompatibility)
+ (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ OverrideImplementation([CALayer class], @selector(setBackgroundColor:), ^id(__unsafe_unretained Class originClass, SEL originCMD, IMP (^originalIMPProvider)(void)) { return ^(CALayer *selfObject, CGColorRef color) { // iOS 13 的 UIDynamicProviderColor,以及 QMUIThemeColor 在获取 CGColor 时会将自身绑定到 CGColorRef 上,这里把原始的 color 重新获取出来存到 property 里,以备样式更新时调用 // 由于上面调试发现 CGColor 存在复用的情况, 所有这里还是能拿到之前关联的QMUIThemeColor // 然后就导致下面 qmui_setNeedsUpdateDynamicStyle 调用时,又被覆盖回去了 UIColor *originalColor = [(__bridge id)(color) qmui_getBoundObjectForKey:QMUICGColorOriginalColorBindKey]; selfObject.qcl_originalBackgroundColor = originalColor; // call super void (*originSelectorIMP)(id, SEL, CGColorRef); originSelectorIMP = (void (*)(id, SEL, CGColorRef))originalIMPProvider(); originSelectorIMP(selfObject, originCMD, color); }; }); }); } - (void)qmui_setNeedsUpdateDynamicStyle { if (self.qcl_originalBackgroundColor) { UIColor *originalColor = self.qcl_originalBackgroundColor; self.backgroundColor = originalColor.CGColor; } }
截图
如何重现 复现QMUIThemeSample.zip
预期的表现 切换系统dark mode都应该是 0x121212
其他信息
The text was updated successfully, but these errors were encountered:
该问题在 #1463 里跟进
Sorry, something went wrong.
已修复该问题,请根据 iOS 版本支持情况选择升级到 4.6.0(iOS 11-16) 或 4.6.1(iOS 13-16)。
No branches or pull requests
Bug 表现
颜色名称:
B1
Light: 0xffffff
Dark: 0x121212
在
BaseViewController viewDidLoad
中默认设置了self.view.backgroundColor = B1
B
页面不支持主题模式,所以在viewDidLoad
中设置了self.view.backgroundColor = UIColorMake(0x12, 0x12, 0x12)
当主题模式设为跟随系统时, 在
A
页面后将系统dark mode
开启, 然后push
到B
页面进入
B
页面后颜色为0x121212
正常, 此时将系统dark mode
关闭后,B
页面变成了0xffffff
不正常通过调试发现一个颜色在多次调用
CGColor
时会出现内存地址一样的情况继续分析发现在
UIColor+QMUITheme.m
CALayer (QMUIThemeCompatibility)
截图
如何重现
复现QMUIThemeSample.zip
预期的表现
切换系统dark mode都应该是
0x121212
其他信息
The text was updated successfully, but these errors were encountered: