UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Buttons in List Sections Footer Text problem with orientation

Forums > SwiftUI

I have this code that allows me to add buttons within the Footer (or header) of a Section

Section(footer:
            HStack {
    Text("By clicking \"Sign Up\", you agree to our")
    CustomButton(mode: .text, label: "Terms of Service") { termsOfService() }
    Text("and")
    CustomButton(mode: .text, label: "Privacy Policy") { privacyPolicy() }
    Text(".")
    }
) {
    CustomButton(mode: .basic,  label: "Sign Up") {
        signUpPressed()
    }
}

On a larger device or landscape orientation, the footer looks fine.

IMG-4311.png

However, once I go portrait, I get multiple lines for each view within the HStack.

IMG-4312.png

Is there a better way to achieve what I need here than an HStack?

thank you, Jayson

2      

If you don't need to support < iOS 15, you can use AttributedString to just have one string with embedded markdown URLs.

Text("By clicking \"Sign Up\", you agree to our [Terms of Service](your URL here) and [Privacy Policy](your URL here).")

See this Five Stars post for an example, particularly the "Custom actions" section.

3      

Interesting. Thanks for this.

2      

This works well. Thanks again @roosterboy

adding the tint modifier

                .tint(Color.red)

will change the link colors.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out 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.