Swift reusable NavigationLink

You can use modifier in extension, like below

extension Text {
    func styledLinkLabel<V: View & ShapeStyle>(with gradient: V) -> some View {
            .frame(minWidth: 0, maxWidth: 250, alignment: .center)
                    .stroke(gradient, lineWidth:15)
                Image(systemName: "person.crop.circle.badge.plus")
                , alignment: .leading)

and apply it

NavigationLink(destination: FairRentView(viewModel: FairRentViewModel(Amounts(), housemates: 2)))
        .styledLinkLabel(with: gradient)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top