1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SwiftUIでNavigationController(NavigationView)

Last updated at Posted at 2020-05-04

##SfirtUIで画面遷移(navigationBar)

swiftUIを用いて画面遷移を行います。
navigationBarのようなものを作成したい時、その前提となる知識です。

遷移元となる画面

import SwiftUI

struct FirstView: View {
    var body: some View {
        
        NavigationView {
            NavigationLink(destination: SecondView()){
                Text("画面遷移")
            }
            .navigationBarTitle("遷移前")
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        FirstView()
    }
}

NavigationLink(destination: 遷移先のView){}を用います。
遷移先のViewに特別に書くことはありません。

import SwiftUI

struct SecondView: View {
    var body: some View {
        Text("Hello, World!")
    }
}

struct SecondView_Previews: PreviewProvider {
    static var previews: some View {
        SecondView()
    }
}
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?