Skip to content
Discussion options

You must be logged in to vote

This is my solution
1-st we need to add some binding and action.

import SwiftUI
struct TabViewCustom: View {
    var views: [TabBarItem]
    @State private var selectedIndex: Int = 0
    @Binding var currentIndex: Int
    let action: () -> Void
    init(_ views: [TabBarItem], currentIndex: Binding<Int>, action: @escaping () -> Void) {
        self.views = views
        _currentIndex = currentIndex
        self.action = action
    }

    var body: some View {
        ZStack {
            ForEach(views.indices) { i in
                self.views[i].view
                    .opacity(self.selectedIndex == i ? 1 : 0)
            }
            GeometryReader { geometry in
                VStack …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dmikots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant