Some (maybe minor) things that I’ve observed while learning SwiftUI and doing some hands on testing:
- When you present a set of unrelated items in a Picker (i.e. without ForEach) or a set of random tab items in a TabView (in similar conditions) you need to tag() them with integer values if you want selection by index to work. (With ForEach you don’t need to – it seems it does it internally?)
- When you create a Button you need to pass its action as the first argument of the initializer, and the content as a last closure. But when you create an Alert.Button the Text is expected as the first argument, and the action as a final closure.
- Corner radius on border modifier is now obsolete. So you are forced to use overlay instead:
Or, if you need a custom background too, this will become an ugly dinosaur with repeating constant:
.cornerRadius(10) // cut background too
- scaleEffect modifier will resize the view but layout won’t be affected, i.e. it might be displayed on top of (or behind) other views. The behavior is the same as for offset but there the “effect” is somehow expected…
- A VStack, HStack, etc. can only contain 10 views added manually into SwiftUI code; you need to use Group to allow more (but that’s OK most of the times).
But there are a lot of good things, too, which I won’t mention since they are everywhere in SwiftUI blog posts, recently. Except for one that I really liked to find out it exists: the .constant binding – very good for prototyping.