Skip to content

[Improvments] Change UITraitCollection.current before layout UI #986

@Ernest0-Production

Description

@Ernest0-Production

There is a global variable UITraitCollection.current that allows you to override the current traitCollection globally, at the stage of rendering the component.

It would be nice to add an override for this variable, since we use this property in SwiftUI in the project and it has a value from the host simulator, and not an overridden one.

The reason is that SwifUI.View.body is rendered at the moment when

config.size = hostingController.sizeThatFits(in: maxSize)

That is, until the moment when it is called:

rootViewController.setOverrideTraitCollection(traits, forChild: viewController)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions