TraitCollectionChange
优质
小牛编辑
128浏览
2023-12-01
DarkMode
模式切换时打印log
模式切换时自动打印log
在Xcode
菜单栏Product->Scheme->Edit Scheme
选择Run
->Arguments
->Arguments Passed On Launch
添加以下命令即可: -UITraitCollectionChangeLoggingEnabled YES
打印信息:
[TraitCollectionChange] Sending -traitCollectionDidChange: to <_UINavigationBarContentView: 0x7ffca640d2f0; frame = (0 0; 414 44); layer = <CALayer: 0x600002f65980>> layout=0x7ffca640d770
► trait changes: { UserInterfaceStyle: Light → Dark }
► previous: <UITraitCollection: 0x600001424750; UserInterfaceIdiom = Phone, DisplayScale = 2, DisplayGamut = P3, HorizontalSizeClass = Compact, VerticalSizeClass = Regular, UserInterfaceStyle = Light, UserInterfaceLayoutDirection = LTR, ForceTouchCapability = Unavailable, PreferredContentSizeCategory = L, AccessibilityContrast = Normal, UserInterfaceLevel = Base>
► current: <UITraitCollection: 0x600001479860; UserInterfaceIdiom = Phone, DisplayScale = 2, DisplayGamut = P3, HorizontalSizeClass = Compact, VerticalSizeClass = Regular, UserInterfaceStyle = Dark, UserInterfaceLayoutDirection = LTR, ForceTouchCapability = Unavailable, PreferredContentSizeCategory = L, AccessibilityContrast = Normal, UserInterfaceLevel = Base>