Post

Replies

Boosts

Views

Activity

Reply to swiftui zstack alignment not working
Mark's answer is correct for, but just to make it clearer. Like the question, I was using ZStack{ // Child content } .frame(width: 200, height: 500, alignment: .topLeading) But this doesn't work, presumably because the frame is adding a parent view to the ZStack, and the alignment is not being added directly to the ZStack itself. By taking the following approach of passing the alignment directly to the ZStack at initialisation, I was able to get the expected results with all children position top left. ZStack(alignment: .topLeading) { // Child content } .frame(width: 200, height: 500, alignment: .topLeading)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21
Reply to Sidebar on the right in SwiftUI
Also looking for something like this myself. I'm trying to attain the same kind of right hand collapsible sidebar as is used in Xcode.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to SwiftUI toolbar action with StateObject causes frame rate to drop
(Accidentally posted this as an answer and can't delete). After some more testing, it's not actually just StateObject. If I add this to the view, and then try to print it in the action, the lag is present. @State var test:Bool = false
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to DragGesture translation reporting incorrect values
Thanks for pointing this out, I missed it completely.. Will still be interested to hear why the positioning results change based on where I click in the Rectangle (i.e why repeated clicks in one spat can have .zero translation, whilst repeated clicks in others don't)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to swiftui zstack alignment not working
Mark's answer is correct for, but just to make it clearer. Like the question, I was using ZStack{ // Child content } .frame(width: 200, height: 500, alignment: .topLeading) But this doesn't work, presumably because the frame is adding a parent view to the ZStack, and the alignment is not being added directly to the ZStack itself. By taking the following approach of passing the alignment directly to the ZStack at initialisation, I was able to get the expected results with all children position top left. ZStack(alignment: .topLeading) { // Child content } .frame(width: 200, height: 500, alignment: .topLeading)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’21