Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

ForEach tabs swiftui

import SwiftUI

struct ContentView: View {
    let tabData = [
        TabItem(title: Text("Tab 1"), image: Image(systemName: "1"), tag: 1),
        TabItem(title: Text("Tab 2"), image: Image(systemName: "2"), tag: 2),
        TabItem(title: Text("Tab 3"), image: Image(systemName: "3"), tag: 3),
        TabItem(title: Text("Tab 4"), image: Image(systemName: "4"), tag: 4)
    ]

    @State private var selectedTab = 0

    var body: some View {

        TabView(selection: $selectedTab) {

            ForEach(tabData) { tabItem in
                Text("Screen: (tabItem.tag)")
                    .tabItem {
                        tabItem.title
                        tabItem.image
                }.tag(tabItem.tag)
            }
        }

    }
}

struct TabItem: Identifiable {
    var id = UUID()
    var title: Text
    var image: Image
    var tag: Int
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift dictionary sorted 
Swift :: swift remove all pins from mapkit 
Swift :: how to Not bool bindng swiftui 
Swift :: swiftui tutorial 
Swift :: swift set keyboard next functionality 
Swift :: swift string format double 
Swift :: swift extension Array with type 
Swift :: Create a Swift Array 
Swift :: convert secondsfrom1970 to date swift 
Swift :: Swift "Hello, World!" Program 
Swift :: swiftui rounded specific corner 
Swift :: two value sum 
Swift :: swift wait until condition is true 
Swift :: table view content size not return correctly 
Swift :: swift disable modal dismiss swift 
Swift :: compactMap 
Swift :: get parent view controller in presentation mode swift 
Swift :: Swift Nested Ternary Operators 
Swift :: access tuple elements 
Swift :: swift chuck array in peases 
Swift :: swiftui profile picture 
Swift :: how to declare populated dictionary in swift 
Swift :: Named Associated Values Swift 
Swift :: Swift Modify the Elements of an Array 
Swift :: ios network request 
Ruby :: how to match email in regex in ruby 
Ruby :: find records created in a particular month rails 
Ruby :: reverse range ruby using steps 
Ruby :: rails on_delete cascade not working 
Ruby :: rails strftime 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =