Skip to content

Instantly share code, notes, and snippets.

@grattours
Created October 27, 2019 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grattours/b962682543e0bf776c404937b9d0b58f to your computer and use it in GitHub Desktop.
Save grattours/b962682543e0bf776c404937b9d0b58f to your computer and use it in GitHub Desktop.
Barre de titre avec bouton et lien
//
// ContentView.swift
// SwiftUIButtonNav
//
// Created by Luc Derosne on 27/10/2019.
// Copyright © 2019 Luc Derosne. All rights reserved.
//
import SwiftUI
struct ContentView: View {
@State var selection: Int? = nil
var body: some View {
NavigationView {
VStack {
HStack {
Image("Tipios")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 70, height: 70, alignment: .leading)
Text("Texte à coté image")
.font(.title)
.bold()
Spacer()
}
NavigationLink(destination: autreView()) {
Text("lien vers autreView")
}.buttonStyle(PlainButtonStyle())
Spacer()
}
.navigationBarTitle("Accueil").navigationBarItems(trailing: NavigationLink(destination: loginView(), tag: 1, selection: $selection) {
Button(action: {
self.selection = 1
}) {
HStack {
Spacer()
Text("Login")
Spacer()
}
}
})
}
}
}
struct autreView: View {
var body: some View {
Text("texte dans autreView")
}
}
struct loginView: View {
var body: some View {
Text("Page de Login")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment