microsoft / FluentDarkModeKit

A library for backporting Dark Mode in iOS
MIT License
1.63k stars 125 forks source link

`dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?)` not called #104

Closed lifution closed 3 years ago

lifution commented 3 years ago

iOS 13 and newer, method dmTraitCollectionDidChange(_ previousTraitCollection: DMTraitCollection?) not called after overrideTraitCollection updated. This problem appeared in UIImageView and UILabel. FluentDarkModeKit version: 1.0.3

levinli303 commented 3 years ago

This is expected. The following classes are known to not call UIView's traitCollectionDidChange thus dmTraitCollectionDidChange cannot be bridged.

UIView subclasses: UIImageView, UILabel, UIDatePicker, UIPickerView UIViewController subclass: UISplitViewController

My suggestion to fix it would be either:

  1. Avoid subclassing these classes, but create a container view for the classes to handle dmTraitCollectionDidChange
  2. Override traitCollectionDidChange and apply the same logic on iOS 13
lifution commented 3 years ago

@levinli303 Get it, thanks.