NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Guys tell me how to implement something like this menu?

Forums > SwiftUI

struct HeaderNavigationView: View {
    //var actionMenu: () -> Void
    //var title: String
    //var subtitle: String

    var body: some View {
        HStack {
            ZStack(alignment: Alignment(horizontal: .leading, vertical: .center)) {
                HStack {
                    VStack {
                        Text("title")
                            .font(.system(size: 20, weight: .light, design: .default))
                            .foregroundColor(.black)
                        Text("subtitle")
                            .font(.system(size: 14, weight: .regular, design: .default))
                            .foregroundColor(.black)
                    }
                }
            }
            Spacer()
            Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/) {
                Image(systemName: "chevron.left")
                    .foregroundColor(.black)
            }
        }
        .frame(width: .infinity)
        .border(Color.red, width: /*@START_MENU_TOKEN@*/1/*@END_MENU_TOKEN@*/)
    }
}

(http://joxi.ru/l2ZYoOzu7ZNyom)

1      

so far I was able to implement like this

struct HeaderNavigationView: View {
    var actionMenu: () -> Void
    var title: String
    var subtitle: String

    var body: some View {
        ZStack {
            GeometryReader { g in
                HStack {
                    Button(action: actionMenu ) {
                        Image(systemName: "chevron.left")
                            .foregroundColor(.white)
                    }
                    VStack {
                        Text(title)
                            .font(.system(size: 20, weight: .light))
                            .foregroundColor(.white)
                        Text(subtitle)
                            .font(.system(size: 14, weight: .regular))
                            .foregroundColor(.powderBlue)
                    }
                    .frame(width: g.size.width)
                    .offset(x: g.safeAreaInsets.leading - 20, y: 0)
                }
            }
        }
        .frame(height: 40, alignment: .top)
        .padding(.horizontal, 15)
    }
}

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.

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.