Lädt...


🔧 Custom Tab Bar in iOS 18 - #30DaysOfSwift


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Day 8: Level Up with a Custom Tab Bar!

In the eighth post of #30DaysOfSwift series, let's make a Custom Tab Bar with animations and icons.

Standard tab bars are fine, but a custom one adds that extra touch!

Image description

Here’s how to implement a custom tab bar with SwiftUI:

Steps to Create a Custom Tab Bar:

1. Set Up the Tab Bar Structure:

import SwiftUI

struct CustomTabBarView: View {
    @State private var selectedTab = 0
    let tabBarItems = ["house.fill", "magnifyingglass", "person.fill"]

    var body: some View {
        VStack {
            Spacer()

            // Main Content
            TabView(selection: $selectedTab) {
                HomeView().tag(0)
                SearchView().tag(1)
                ProfileView().tag(2)
            }

            // Custom Tab Bar
            HStack {
                ForEach(0..<tabBarItems.count, id: \.self) { index in
                    Spacer()

                    Button(action: {
                        withAnimation(.spring()) {
                            selectedTab = index
                        }
                    }) {
                        VStack {
                            Image(systemName: tabBarItems[index])
                                .font(.system(size: 24))
                                .foregroundColor(selectedTab == index ? .blue : .gray)
                                .scaleEffect(selectedTab == index ? 1.2 : 1.0) // Add animation for scaling

                            Text(tabName(for: index))
                                .font(.caption)
                                .foregroundColor(selectedTab == index ? .blue : .gray)
                        }
                        .padding(.vertical, 10)
                    }

                    Spacer()
                }
            }
            .padding(.bottom, 20)
            .background(Color.white.shadow(radius: 10))
        }
    }

    func tabName(for index: Int) -> String {
        switch index {
        case 0: return "Home"
        case 1: return "Search"
        case 2: return "Profile"
        default: return ""
        }
    }
}

struct HomeView: View {
    var body: some View {
        Text("Home Screen")
            .font(.largeTitle)
            .foregroundColor(.blue)
    }
}

struct SearchView: View {
    var body: some View {
        Text("Search Screen")
            .font(.largeTitle)
            .foregroundColor(.green)
    }
}

struct ProfileView: View {
    var body: some View {
        Text("Profile Screen")
            .font(.largeTitle)
            .foregroundColor(.purple)
    }
}

Happy Coding!

...

📰 Samsung Tab Time: Bis zu 100 Euro Cashback für Galaxy Tab S7+, Tab S7, Tab S6 Lite und Tab S5e


📈 41.23 Punkte
📰 IT Nachrichten

📰 Custom New Tab URL: Anpassung der Neuer-Tab-Seite in Chrome


📈 23.98 Punkte
📰 IT Nachrichten

🪟 Google Chrome for Android will soon let you add custom actions in Chrome Custom Tab (CCT)


📈 23.22 Punkte
🪟 Windows Tipps

🍏 Google Prepares New Tab Page Customization for Chrome on iOS, Including Custom Wallpapers


📈 18.96 Punkte
🍏 iOS / Mac OS

🍏 Customize menu bar on Mac: Rearrange, add, and remove menu bar items with ease


📈 18.51 Punkte
🍏 iOS / Mac OS

📰 Xbox Game Bar: How to Open Game Bar (Windows 10)


📈 18.51 Punkte
🖥️ Betriebssysteme

📰 Galander Bar in Berlin-Kreuzberg: So war mein Abend in einer virtuellen Bar


📈 18.51 Punkte
📰 IT Nachrichten

📰 I Miss My Bar: Bar-Klänge für das Wohnzimmer


📈 18.51 Punkte
📰 IT Nachrichten

📰 Touch Bar: TouchSwitcher mit Big Sur-Support & neue Force Touch Bar patentiert


📈 18.51 Punkte
📰 IT Nachrichten

📰 How to hide the search bar on the title bar in Office 365


📈 18.51 Punkte
🖥️ Betriebssysteme

📰 Firefox 57 Will Hide Search Bar and Use a Uni-Bar Approach, Like Chrome


📈 18.51 Punkte
📰 IT Security Nachrichten

📰 YouTube Testing Seek Bar Preview and Bottom Bar UI on Android


📈 18.51 Punkte
📰 IT Security Nachrichten

📰 Touch Bar MacBook Pros Are Being Banned From Bar Exams Over Predictive Text


📈 18.51 Punkte
📰 IT Security Nachrichten

🔧 How to visualize bar chart with react-chart-2, showing label on the bar


📈 18.51 Punkte
🔧 Programmierung

📰 MacBook Pro’s Touch Bar Banned During Bar Exams Due to Cheating Concerns


📈 18.51 Punkte
📰 IT Security Nachrichten

🪟 Explorer Address bar and Menu bar is missing in Windows 11


📈 18.51 Punkte
🪟 Windows Tipps

🔧 How to set the bar width of a bar chart in VChart


📈 18.51 Punkte
🔧 Programmierung

🪟 Chrome on Android tests bookmark bar, PDF assist content, & new tab animation features


📈 17.5 Punkte
🪟 Windows Tipps

🪟 Show or hide Tab Groups Icon in Chrome bookmarks bar


📈 17.5 Punkte
🪟 Windows Tipps

🪟 This is how desktop Chrome’s new feature helps you in decluttering Tab bar


📈 17.5 Punkte
🪟 Windows Tipps

🔧 Animated Tab Bar Using HTML and CSS || Free Source Code


📈 17.5 Punkte
🔧 Programmierung

📰 Vivaldi 3.6 Launches with a Second Tab Bar


📈 17.5 Punkte
📰 IT Security Nachrichten

🐧 The Kate Text Editor and the Tab Bar - Release 20.12


📈 17.5 Punkte
🐧 Linux Tipps

🪟 How to hide the Bookmarks bar from the New Tab page in Chrome on Windows 10


📈 17.5 Punkte
🪟 Windows Tipps

📰 How to hide the Bookmarks bar from the New Tab page in Chrome on Windows 10


📈 17.5 Punkte
🖥️ Betriebssysteme

📰 Mozilla Makes It Easier to Hide Tabs in Firefox and Unclutter Your Tab Bar


📈 17.5 Punkte
📰 IT Security Nachrichten

🍏 How To Add A Custom Button To The Touch Bar In macOS


📈 16.74 Punkte
🍏 iOS / Mac OS

📰 How To Add A Custom Button To The Touch Bar In macOS


📈 16.74 Punkte
🖥️ Betriebssysteme

📰 Set A Custom Color For The Navigation Bar On Android [No Root]


📈 16.74 Punkte
🖥️ Betriebssysteme

🍏 Creating a Custom Weather and Home Climate Control Menu Bar App with MenuBot and Shortcuts


📈 16.74 Punkte
🍏 iOS / Mac OS

matomo