I am looking at this SwiftUI tutorial and it suggests I can see extra actions upon Command-Clicking the SwiftUI elements in code. In my Xcode, this jumps me to the class definition.
I see there's an option in XCode 11.0 t change the Option key to show SwiftUI inspector, however, this still does not let me modify SwiftUI code elements using actions like "Embed in VStack"
How can I get both inspector and extra SwiftUI actions when interacting with SwiftUI Code (not the preview)?
In the Project navigator, click to select ContentView.Command-click the text view to show the structured editing popover, and then choose Embed in VStack. Also set the font of the Vstack to . largeTitle using the font modifier. The preview shows the two text views vertically stacked.
Like Java, C++, PHP, and C#, Swift is an imperative programming language. SwiftUI, however, is proudly claimed as a declarative UI framework that lets developers create UI in a declarative way.
VStack. The VStack allows you to stack views vertically, from top to bottom. You can further customize the view by adding alignment or spacing to the VStack. VStack(alignment: . leading, spacing: 16) { Text("Hello, world!") .
Individually, HStack , VStack , and ZStack are simple views. HStack positions views in a horizontal line, VStack positions them in a vertical line, and ZStack overlays views on top of one another.
Extra SwiftUI actions show when Canvas is opened (shortcut: Option-Command-Enter or ⌥+⌘+↵):
canvas is closed
canvas is opened
Instead of using the mouse, I recommend using the Xcode hotkey for bringing up code actions. Navigate to Preferences -> Key Bindings and search for Show Code Actions
. You'll see the preset hotkey which you can then customize. My default key binding was Shift
+Command
+A
. Just make sure you cursor is over the intended element when you press the hotkey.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With