4 ms·
SwiftUI has defaults because nobody knew what UIKit's were supposed to be. Some of them were fiddly secret layout guides in Interface Builder, and some were acc
by saagarjha 7y ago
SwiftUI has defaults because nobody knew what UIKit's were supposed to be. Some of them were fiddly secret layout guides in Interface Builder, and some were accessed through the magic "-" in a VFL constraint, but overall it was very difficult to actually know how much spacing things should have. And on Apple's platforms, this matters: users know what things should look like, and if you're off you just look out of place. And if they change in the future, which they have on occasion due to new iOS versions or hardware (iPhone X, anyone?) you might end up off even if you didn't change anything in your code.
SwiftUI intentionally abstracts all of these things away from you so you don't have to deal with it, or even know about it. You're used to programming on the web? Well, the web has no standard. And anyways, people looking for magic defaults is how "8" and "44" show up seemingly randomly in iOS apps. Let the system decide for you…if you really need to override it, you can add your own explicit value.
- nwienert 7y agoYea, well said. There are some awkward bits, but if I were writing an article on my first 4 months with SwiftUI it would look totally different. There are tons of bugs, random issues, and a lack of controllable properties in areas. There’s a lack of documentation, performance, etc. But the language, defaults, components? All wonderfully done. In fact I’d spend years building a UI kit in React attempting to standardize on things like that, and on seeing and using SwiftUI I was constantly impressed by how well done it all feels when the language (Swift) is robust and designed to work alongside the framework. Count me as basically optimistic, just hoping they iron out all the beta-y aspects quick!
- LeoNatan25 7y agoUIKit has enough abstraction to allow not knowing the magic numbers and looking right. What with safe areas, margins and reading guides, all this has been possible for many years now. The problem isn’t the API; it’s terrible product managers and designers, usually from the web world, who think they know better and ignore platform APIs for hard coded numbers. SwiftUI won’t save those clowns from themselves unless it completely takes control out of their hands, like WatchKit.