Equivalent to UIApplication.shared.preferredContentSizeCategory in application extension

My open source library should be able to call UIApplication.shared.preferredContentSizeCategory . But UIApplication.shared not available in extensions. The build error says that I find a method based on the view of the controller to solve my problem, but I am writing a library, so I do not have access to any view controllers. Is there a way to get the extension root view controller or a way to get an external UITraitEnvironment ?

I support iOS 9+, but this feature can be 10+ if that allows.

+5
source share
1 answer

You can use UIScreen.main.traitCollection.preferredContentSizeCategory . The preferredContentSizeCategory property is available on iOS 10 or later.

+1
source

Source: https://habr.com/ru/post/1262061/


All Articles