Post

Replies

Boosts

Views

Activity

Reply to VStack adds a space when I have a ZStack with multiple items inside
The vertical spacing is set by the VStack. If the VStack's "spacing" is nil, then the stack will "choose a default distance for each pair of subviews". As you are seeing, this distance is not necessarily the same for every pair of views. It's not possible to specify the spacing within the VStack. The only way to enforce the VStack spacing of 0 is to use: VStack(alignment:.leading, spacing: 0) { ...which you can't do. So I think you are stuck.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22
Reply to How to create a DetailView in SwiftUI?
You have defined "viewAllArtwork" in "ArtworkDetailView" You are trying to reference it in "ArtworkDetailView_Previews", which is a completely different thing. Hence the error message. In ArtworkDetailView_Previews, you need to create a single Artwork, and pass it to the ArtworkDetailView. You have not included the code for Artwork, so I can't suggest how you create that. Typically, it would be something like: ArtworkDetailView(artwork: Artwork())
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22
Reply to Button That Changes Label on Click
Try this: import SwiftUI struct ButtonTest: View { @State private var isOn = false var body: some View { Button { isOn.toggle() } label: { Image(systemName: isOn ? "star" : "star.fill") } } } struct ButtonTest_Previews: PreviewProvider { static var previews: some View { ButtonTest() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22