No Replacement for deprecated TraitCollectionDidChange · Issue #19410 · dotnet/macios (original) (raw)

I was using traitcollectiondidchange to detect changes of the dark/light theme. That method has been deprecated with iOS 17

Screenshot 2023-11-08 at 1 27 24 PM

The suggested alternative by Apple is registerfortraitchanges, which can be called on objects that implement UITraitChangeObservable (IUITraitChangeObservable interface in C#). UIView and UIViewController seem to implement that interface, but this isn't reflected in the C# bindings - the method RegisterForTraitChanges doesn't exist for UIView and UIViewController. How can I use this new API in .NET?

Screenshot 2023-11-08 at 1 25 32 PM

Environment

.NET 8 RC2.2