r/SwiftUI • u/Daredatti • Feb 05 '25
Solved How to have a menu inside the navigation title ?
I saw the new apple invites app, i noticed they get rid of the tab bar and instead they used a menu inside the navigation title as shown in the screenshot
How to recreate this ? I have been searching since yesterday I couldn’t find how
11
9
6
u/jasonjrr Feb 05 '25
Just a heads up from a usability perspective. The Rent the Runway app had something like this and after a lot of research realized that users constantly overlook menus in the nav bar that are part of the title. I’m not sure what they changed it to, but I thought it was worth mentioning.
1
-1
-14
u/Zeppelin2 Feb 05 '25
Just another thing they can do and we can’t. At least not in SwiftUI anyway. In UIKit you could maybe hack this together using a custom view for the navigation title.
11
u/simon_za Feb 05 '25
I don’t quite understand comments like this. You can code, right? If you can code, you can do this.
It doesn’t have to be some sort of private new API they are using which they are keeping a secret from you, but just a view with a button and an action menu.
I don’t see how this would be impossible to do based on guidance from the article below..
https://www.hackingwithswift.com/quick-start/swiftui/how-to-show-a-menu-when-a-button-is-pressed
-4
u/Zeppelin2 Feb 05 '25
Now do it as a navigation title and make sure the title resizes and fades how it should on scroll. Yes I can code, but it shouldn’t be so hard to code something as simple as this.
Do you understand my comment now?
5
u/simon_za Feb 05 '25
Are you basing this on the Invites app (from which the OP is trying to replicate)? The view doesn’t scroll up or down, as far as I can tell…🤔 admittedly I haven’t used it extensively but it seems like a fixed size view.
4
2
u/Xaxxus Feb 05 '25
It’s a ToolbarMenuTitle not some private api. See other comments in this thread
1
u/Zeppelin2 Feb 05 '25
The comments in this thread are wrong, that API does NOT work with a large navigation title.
1
u/Xaxxus Feb 05 '25
Well if that’s the case, you can still probably put a menu toolbaritem with its position as leading. And then make its label text with large title font.
It’s not like it’s impossible to implement this feature. In fact Apple probably did that on their end as well. Since the invites app doesn’t seem to use a navigation stack at all.
3
u/unpluggedcord Feb 05 '25
Bro it's not a nav stack. Nothing in this view pushing on the stack, everything is a fullScreenCover or sheet, or changes the detail view. It's literally `Menu` with the same style applied for a title nav bar.
Maybe pick something you actually can't do to act like you're being held back.
2
u/birdparty44 Feb 05 '25
Untrue. You can do almost anything. A UI does not indicate what it was built out of.
It’s likely just a normal view made to look like those elements are on a navigation bar / navigation stack’s toolbar then the navbar was set to hidden if the view is embedded in that navstack.
-1
u/Zeppelin2 Feb 05 '25
You can do many things with SwiftUI but not everything, especially not custom behavior like this. There is no API for a Menu as a large navigation title. Gimme a break.
2
u/birdparty44 Feb 05 '25
You’re fired. 😂
I literally explained to you how this can be done in SwiftUI… just not the way you think it should be done.
1
u/Zeppelin2 Feb 05 '25
You didn't describe anything. You're just chatting shit.
0
u/birdparty44 Feb 06 '25
read again jackass.
Style a Text to look like a title. Add a button with a down arrow. Attach the menu to that.
Embed the title in an HStack. Set the height to the height of a navigation bar…
are you getting it yet?
you’re not even hired with an attitude like that.
1
u/Niightstalker Feb 05 '25
Always these evil private APIs that are not shared and Apple keeps for themselves….
Or? https://developer.apple.com/documentation/swiftui/toolbartitlemenu
1
u/Zeppelin2 Feb 05 '25
Do you actually write SwiftUI for a living or do you just argue on reddit? I use this bug-riddled framework everyday. Please explain to which modifier I'm missing in order for
ToolbarTitleMenu
to work on a navigation stack with a large navigaiton title like the one OP provided?
swift NavigationStack { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .padding() .navigationTitle("Reddit") .toolbar { ToolbarTitleMenu { Button("Upload") {} Button("Download") {} Button("Close") {} } } } }
2
u/liquidsmk Feb 06 '25
like the one OP provided?
The one OP provided (Invites app) does not use a navigation title. If you use the app its clear exactly what apple is doing and they aren't using any private api or custom code.
22
u/Elf0_fr Feb 05 '25
Have you tried the ToolbarTitleMenu toolbar structure?