Questions tagged [uitraitcollection]

UITraitCollection - allow to access the iOS interface environment by traits such as horizontal and vertical size class, display scale, and user interface idiom

84 questions
3
votes
0 answers

How to know centrally when the UI style (dark/light) changes in iOS?

I have an iOS app that had its own theming system (dark/light UI styling) before iOS 13 introduced it natively. This is partly achieved via the UIAppearance methods on various UI elements, like bar button items, segmented controls, and such. To…
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
3
votes
1 answer

what are the size classes for the new iPhone X models?

Apple has introduced three new iPhone X models: the iPhone XR, XS, and XS Max. What are their size classes, and how do these compare to other iPhone models?
matt
  • 515,959
  • 87
  • 875
  • 1,141
3
votes
3 answers

traitCollection.preferredContentSizeCategory.isAccessibilityCategory for iOS 10

The following code works great on iOS11 to detect if the user has set LARGE FONT in their accessibility settings. However, I need to support this in iOS10 as well. How can I accomplish this? Right now the code looks like this: if #available(iOS…
Jeff
  • 1,800
  • 8
  • 30
  • 54
3
votes
1 answer

landscape left or right in terms of traitCollection and size classes?

I've learned the Auto Layout, UITraitCollection and size classes to make adaptive UI. But I understand that I'm missing one thing. Put it simple: I want my UI stick to home button just like the native camera app does. To do this I specify the…
Grigory
  • 992
  • 2
  • 18
  • 34
3
votes
1 answer

UITraitCollection and UISplitViewController on iPad

I am designing an iPad app using a UISplitViewController. I have configured the UISplitViewController such that the master view controller (i.e. the thinner view on the left-hand side) is always visible via splitViewController.preferredDisplayMode =…
Skoota
  • 5,280
  • 9
  • 52
  • 75
3
votes
2 answers

UISplitViewController: How to prevent expansion when rotating from Compact to Regular

There are many answers to the complementary question, which is how to prevent a transition to PrimaryOverLay on a from Regular to Compact interface change, eg use func splitViewController(splitViewController: UISplitViewController,…
David H
  • 40,852
  • 12
  • 92
  • 138
3
votes
0 answers

UITraitCollection remains same for iPhone / iPad

In iOS 8.3, I present a view controller with the following code: UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller]; nav.modalPresentationStyle =…
Guven
  • 2,280
  • 2
  • 20
  • 34
2
votes
2 answers

Why is traitCollectionDidChange not called for a table view cell when content size category changes?

I have a view controller that contains a table view and displays custom cells. I'm trying to react to a content size category change using the traitCollectionDidChange method (within the cell subclass), but this method is never called for the cells…
Brian Spilner
  • 581
  • 1
  • 5
  • 12
2
votes
0 answers

Is there a situation when traitCollectionDidChange is the only function that can not be substituted by willTransition?

Apple says that traitCollectionDidChange(... called when the iOS interface environment changes and willTransition(to:with:) Notifies the container that its trait collection changed. ok. but is there a code i must call strictly in…
Ninja
  • 309
  • 7
  • 26
2
votes
2 answers

How to specify a minimum UIContentSizeCategory for UIFontMetrics?

I have a method for creating an auto-scaling font based on Dynamic Type that looks like so: extension UIFont { public static func getAutoScalingFont(_ fontName: String, _ textStyle: UIFont.TextStyle) -> UIFont { // getFontSize pulls from…
WongWray
  • 2,414
  • 1
  • 20
  • 25
2
votes
0 answers

traitCollectionDidChange not called on custom UIView subclass when switching to Dark Mode

I have created a custom UIImageView subclass which adds some custom drawing. This works fine but now I would like to adapt the class to work with iOS 13 Dark Mode. I added traitCollectionDidChange: to the class to get notified of style changed and…
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
2
votes
1 answer

Darkmode and multiwindows / scenes

i'm trying to implement ios13 darkmode within multi scene application. Unfortunately when i dismiss a scene dragging it over the screen edge the method traitCollectionDidChange is called several times with always different values, causing my UI to…
Fabiosoft
  • 1,141
  • 14
  • 32
2
votes
0 answers

In iOS 13 - How can we implement more than two color modes / themes?

Looking at the brand new WWDC video Implementing Dark Mode on iOS we see that it can be handled quite easily. We can use the new dynamic system colors and they will have specific values depending on Light or Dark Mode. Now, how can this new concept…
HelloTimo
  • 558
  • 1
  • 5
  • 18
2
votes
1 answer

When is the size class properly set?

I'm trying to test some size-class specific traits in my unit tests, but am running into an issue where the size class is not properly set in awakeFromNib. When I run the app, it is set correctly by inspecting it in LLDB after everything is on…
Bill L
  • 2,576
  • 4
  • 28
  • 55
2
votes
2 answers

Xcode simulator not calling traitCollectionDidChange

I am overriding traitCollectionDidChange(_) to update my compact and regular constraints. When I test this on a device by rotating the constraints get updated correctly. When I however try to test the same code in the simulator nothing happens. I…
Joseph
  • 9,171
  • 8
  • 41
  • 67