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      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.