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

SOLVED: How to make a NavigationLink label rectangular on watchOS?

Forums > SwiftUI

I'm trying to create a 2 x 2 layout of NavigationLinks on watchOS 9.

I get everything working fine using HStacks within a VStack.

My problem is how to make the NavigationLinks appear as rectangles?

I've tried various things but they always appear as capsules.

Here's the code for one link:

NavigationLink {

                AuxiliaryStorageView(request: rqs2)
            }
            label: {

                Image(systemName: "externaldrive.connected.to.line.below")
                     .resizable()
                     .scaledToFit()

            }

Any assistance in making this appear as a rectangle rather than a capsule would be very much appreciated.

Many thanks.

2      

Hi, You could try adding .buttonBorderShape(.roundedRectangle(radius: 0)) to the Label.

NavigationLink {
    AuxiliaryStorageView(request: rqs2)
} label: {
    Image(systemName: "externaldrive.connected.to.line.below")
     .resizable()
     .scaledToFit()
}
.buttonBorderShape(.roundedRectangle(radius: 0))

2      

Thank you!

I now have my 2 x 2 rectangles ... most appreciated!

2      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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

Reply to this topic…

You need to create an account or log in to reply.

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.