NEW: Get your ticket to Hacking with Swift Live! >>

What can SwiftUI do better than UIKit?

Recorded – watch the full episode on YouTube.

So compared to UIKit, would you say there are certain types of designs that SwiftUI make easier to do than UIKit would have done?

Meng To: I think it's easier to do custom designs for sure, just because there's very little cost to changing the layout, to maintain the layout. If you think about UIKit, for example, you have to use constraints and constraints are extremely hard for anyone, not just for designers, but also for developers. And I feel for developers because in the design tool now we are using constraints and a lot of designers have trouble with that.

Imagine in the design tool, having trouble with constraints, being the person who designed the layout themselves, having trouble with constraints. And as we all know in UIKit is like 10X that's complexity of what you can find in Figma or in Sketch. In Figma and Sketch you only have like, Oh, you can go from top, from the left. You don't even have specific units for those distances.

“The reason why I say I feel for developers is because developers are not necessarily the one who created the layout. And as someone who didn't create a layout to have to go into the constraint mode, which is a very mental modal for a designer is very difficult.”

It's just, “hey, I want to do a constraint from the top, from the left and whatever distance that I already have right now it's just going to stick to it.” But in UIKit it's much more complex. You can sort of set constraints between two elements. You can align them with each other. You can set a priority of constraints, and then you have fixing constraints, you have a Stacks that comes along with it.

It's very complex, even for a designer. Now, the reason why I say I feel for developers is because developers are not necessarily the one who created the layout. And as someone who didn't create a layout to have to go into the constraint mode, which is a very mental modal for a designer is very difficult.

“You're not going to have conflicts. You're not going to have to maintain it as much. It's like SwiftUI was made to be adaptive from the beginning.”

For me as a designer, I created a layout. So I understand everything, every bits and pieces, all the distances, all the paddings. And when I go to a storyboard, I understand how to set up the constraints, but having someone else do it for me, I feel for that person, which is why I feel like it's very difficult. Now, compared to auto layout, well not UIKit Auto Layout – I mean Figma's auto layout, which is comparable to stacks in SwiftUI.

It's extremely easy for anyone to set up stacks. You just select a bunch of elements, put them into stacks, and set the distances. Everyone can understand that. And you're not going to have conflicts. You're not going to have to maintain it as much. It's like SwiftUI was made to be adaptive from the beginning.

“The way that you have to set up your mind to think about those layouts is very different from the way that we have to think about layouts nowadays, just because of sheer amount of devices out there.”

And that I think is a very powerful concept versus a UIKit. When it was invented, we had very few screens at the time. And I think we started like even at 1X screen in term of resolution. So the way that you have to set up your mind to think about those layouts is very different from the way that we have to think about layouts nowadays, just because of sheer amount of devices out there.

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

Hacking with Swift is sponsored by Essential Developer

SPONSORED From August 2nd to 8th you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!

Save your spot now

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

BUY OUR BOOKS
Buy Pro Swift 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 (Vapor Edition) 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 Server-Side Swift (Kitura Edition) 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.