UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

macOS SwiftUI Nagivation

Forums > SwiftUI

I'm attempting to create a settings view for my MacOS swiftUI status bar app. My implementation so far has been using a NavigationView, and NavigationLink, but this solution produces a half view as the settings view pushes the parent view to the side. Code example and screenshot below.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack{
            NavigationView{
            NavigationLink(destination: SecondView()){
                Text("Go to next view")
                }}
        }.frame(width: 800, height: 600, alignment: .center)}
}

struct SecondView: View {
    var body: some View {
        VStack{

                Text("This is the second view")

        }.frame(width: 800, height: 600, alignment: .center)
    }
}

The little information I can find suggests that this is unavoidable using SwiftUI on MacOS, the 'full screen' nagivation view on iOS is not available on macOS.

Is there a simple or even complex way of implementing a transition to a settings view that takes up the whole frame in SwiftUI for MacOS? And if not, is it possible to use AppKit to call a View object written in SwiftUI?

Also a Swift newbie - please be gentle.

3      

You can get the full screen navigation with

 .navigationViewStyle(StackNavigationViewStyle())

3      

Ahh if only it was that simple, I get a build error "StackNavigationViewStyle' is unavailable in macOS".

4      

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.