TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Advanced Geometry?

Forums > SwiftUI

Hi, I have a Geometry to align two HStacks vertically.

The second row of my VStack has three individual returns. I separated them as separate elements so I can align them vertically.

If I make all three variables as one element so I can apply a modifier, is it still possible to align them vertically?

Or vice versa?

The second row which has the "deriveVibration" function has three variables V, C, and T which has diferrent result as the variables on top deriveV, deriveC, and deriverawTotal.

How do I apply this modifier? Text(deriveVibration(string: .font(.largeTitle) { if Text(deriveT(string: = 4, 6, or 8 { .foregroundColor(Color.Green) } else .foregroundColor(Color.White) }

Thank you for any suggestions you may have.

My current code below is set as one element. How can I align them individually without breaking them apart?

   GeometryReader { proxy in
 VStack(spacing: 0) {
    HStack {
            .frame(width: proxy.size.width * 0.04, alignment: .top) .fixedSize()
            .frame(width: proxy.size.width * 1, alignment: .top) .fixedSize()
         .frame(idealWidth: 8, maxHeight: 88)


Did you try using an alignment parameter on your HStack?

HStack(alignment: .top) {


Yes, it didn't change anything. I should mention that the top row is a smaller size than the bottom row and the top row could show a two digit per box whereas the bottom will always have a single digit per box.


Check out custom Alignment Guides. Very powerful, and simple to use!

There's also a great video from WWDC2019 'Building Custom Views in SwiftUI', which demonstrates custom alignment guides starting at about the 20m50s mark:


Thank you, I will look into this.


Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.