79485679

Date: 2025-03-05 06:58:45
Score: 1
Natty:
Report link

I need more information about what you mean by "doesn't work".

Did you check each UITraitEnvironment‘s traitCollection?
Or is your color or image not changing automatically?
Or are you using cgColor or another non-dynamic property and it doesn’t update automatically?

For now, I can recommend the following solution.

    let traitCollection = UITraitCollection(userInterfaceStyle: .dark)
    myChildView.overrideUserInterfaceStyle = traitCollection.userInterfaceStyle
    traitCollection.performAsCurrent {
        myChildView.backgroundColor = .systemBackground
        myChildView.layer.borderWidth = 10
        myChildView.layer.borderColor = UIColor.systemBackground.cgColor
    }
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Anna Han