UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Tips for working with adaptive layouts

Recorded – watch the full episode on YouTube.

So what tips do you have for helping folks have an easier time when they want to have a great UI on iPhone and iPad, portrait landscape, split screen, slide over – what tips do you have for helping them get great adaptive layouts?

Janina Kutyn: I think the main tip is what I've said probably four times now: think about it from the start. The more you think, the more legwork you do at the beginning, the easier it will be to just make it happen. But other than that, I think just, just leverage the things that you think it provides you.

Like if you're using collection view, you can change the grid layout. You can make more columns, you can make bigger cells. And also maybe it helps to even look at filling the iPad screen with something exciting – you have so much more of a screen in front of you.

“Think about it from the start. The more you think, the more legwork you do at the beginning, the easier it will be to just make it happen.”

If we really think about our users and if we're really trying to put ourselves into our user's shoes, then it will be clear like what they want to get out of the apps we're building. So what, what kind of experience would they want to have on the iPad? Do they want everything right there on this one screen? Okay. How can I make that happen?

Or do they need to be able to click this button as soon as they get to the screen? How can I make that happen for them? And that's not really just for like adaptive UI layout – that's that's more really for any app we're building.

“40% of users were changing their font size, and most of them were actually changing it to be smaller, not larger. Like, so why is that like, so what is, what does that mean? What do I need to support in my app? You really need to think about your users basically.”

Also another thing is a lot of people do change their font sizes. And in fact, I think some numbers have found that there's a study or I think Peter Steinberg from PSPDFKit had published on their blog. They had published there that they had found that something like 40% of users were changing their font size, and most of them were actually changing it to be smaller, not larger. What does that mean? What do I need to support in my app? You really need to think about your users basically.

Paul Hudson: Right. And would you say that adding callbacks or things like traitCollectionDidChange(), is that part of it as well? Or would you rather leave that as a last resort?

Janina Kutyn: I think so. You can use those to override trait collection for a child view controller of your view controller. And I use that when already the existing size classes or are not enough. And I just want something a little different, like for example if on the one-third split screen, I want that to be treated kind of closer to compact in appearance. So that's the kind of scenario in which I would override the trait collection for a child view controller. And I would do that on like trait collection to change, for the initial trait collection change.

This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.

Listen on Apple Podcasts

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.