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
}
Also in Swift:
- register for remote notifications swift
- how to pass state variable in swiftui
- swift subtract dates
- how to get ride of back button in navbar xcode
- how to use 2 alerts in swiftui
- index string swift
- change font swiftui
- swift has Top Notch
- how to show notification icon on tabbar item swift
- IOS create UIAlertViewController programmatically
- use timer swift
- how to add an underline to a textField swift
- xcode combine calayer into an image
- swift 5 progress bar height
- array swift
- pop the view controller xcode
- swift self.present full screen
- swift set uiimage color
- how do i have countdown timer in swift stackoverflow
- how to recieve hex value from NSData swift
- swift change navigation bar title
- swift function in a variable
- UI API called on a background thread
- swift increase int value