Answers for "swiftui navigation bar"

3

add navigation bar button swiftui

.navigationBarItems(
    leading: Button(action: {
        // Actions
    }, label: { Text("Button") }),

    trailing: Button(action: {
    // Actions
    }, label: { Image("Icon") })
)
Posted by: Guest on March-14-2020
1

swift add navigation bar

override func viewDidLoad() {
    super.viewDidLoad()
    self.setNavigationBar()
}

func setNavigationBar() {
        let screenSize: CGRect = UIScreen.main.bounds
        let navBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: screenSize.width, height: 44))
        let navItem = UINavigationItem(title: "")
        let doneItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.done, target: nil, action: #selector(dissmissView))
        navItem.rightBarButtonItem = doneItem
        navBar.setItems([navItem], animated: false)
        self.view.addSubview(navBar)
    }

@objc
    func dissmissView(){
        self.dismiss(animated: true, completion: nil)
    }
Posted by: Guest on January-20-2021
0

swift add navigation bar

let navBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 44))
view.addSubview(navBar)

let navItem = UINavigationItem(title: "SomeTitle")
let doneItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(selectorName:))
navItem.rightBarButtonItem = doneItem

navBar.setItems([navItem], animated: false)
Posted by: Guest on January-20-2021
0

swiftui navigation button

ForEach (self.drinks, id: \.name)
{
  drink in

  //detail: The SwiftUI view you want to go to
  NavigationLink(destination: DrinkDetail(drink: drink))
  {
    //the button/image you click on to go to that view
    DrinkItem(drink: drink)
    .frame(width: 300)
    .padding(.trailing, 30)
    
    
  }

}
Posted by: Guest on January-07-2020
0

navigation bar title ios 13 siwftui

import SwiftUI

// 1.
struct People: Identifiable{
    var id  = UUID()
    var name = String()
}

struct ContentView: View {
    // 2.
    let people: [People] = [
        People(name: "Bill"),
        People(name: "Jacob"),
        People(name: "Olivia")]
    
    var body: some View {
        NavigationView {
            // 3.
            List(people) { listedPeople in
                NavigationLink(destination: DetailView(name: listedPeople.name)) {
                    VStack(alignment: .leading){
                        Text(listedPeople.name)
                    }
                }
            }
            // 4.
            .navigationBarItems(leading:
            HStack {
                Button(action: {}) {
                    Image(systemName: "minus.square.fill")
                        .font(.largeTitle)
                }.foregroundColor(.pink)
            }, trailing:
            HStack {
                Button(action: {}) {
                    Image(systemName: "plus.square.fill")
                        .font(.largeTitle)
                }.foregroundColor(.blue)
            })
                // 5.
                .navigationBarTitle(Text("Names"))
        }
    }
}
// 6.
struct DetailView: View {
    var name: String
    
    var body: some View {
        Text("current name is: \(name) ")
         // 7.
        .navigationBarTitle(Text("Current Name"), displayMode: .inline)
    }
}
Posted by: Guest on October-24-2020

Code answers related to "swiftui navigation bar"

Code answers related to "Swift"

Browse Popular Code Answers by Language