BillionaireClubCollc
  • News
  • Notifications
  • Shop
  • Cart
  • Media
  • Advertise with Us
  • Profile
  • Groups
  • Games
  • My Story
  • Chat
  • Contact Us
home shop notifications more
Signin
  •  Profile
  •  Sign Out
Skip to content

Billionaire Club Co LLC

Believe It and You Will Achieve It

Primary Menu
  • Home
  • Politics
  • TSR
  • Anime
  • Michael Jordan vs.Lebron James
  • Crypto
  • Soccer
  • Dating
  • Airplanes
  • Forex
  • Tax
  • New Movies Coming Soon
  • Games
  • CRYPTO INSURANCE
  • Sport
  • MEMES
  • K-POP
  • AI
  • The Bahamas
  • Digital NoMad
  • Joke of the Day
  • RapVerse
  • Stocks
  • SPORTS BETTING
  • Glamour
  • Beauty
  • Travel
  • Celebrity Net Worth
  • TMZ
  • Lotto
  • COVD-19
  • Fitness
  • The Bible is REAL
  • OutDoor Activity
  • Lifestyle
  • Culture
  • Boxing
  • Food
  • LGBTQ
  • Poetry
  • Music
  • Misc
  • Open Source
  • NASA
  • Science
  • Natural & Holstict Med
  • Gardening
  • DYI
  • History
  • Art
  • Education
  • Pets
  • Aliens
  • Astrology
  • Farming and LiveStock
  • LAW
  • Fast & Furious
  • Fishing & Hunting
  • Health
  • Credit Repair
  • Grants
  • All things legal
  • Reality TV
  • Africa Today
  • China Today
  • "DUMB SHIT.."
  • CRYPTO INSURANCE

Custom Tab Bar in iOS 18: 30 Days of Swift

Day 8: Level Up with a Custom Tab Bar!
\
In the eighth post of the #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!

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!

Welcome to Billionaire Club Co LLC, your gateway to a brand-new social media experience! Sign up today and dive into over 10,000 fresh daily articles and videos curated just for your enjoyment. Enjoy the ad free experience, unlimited content interactions, and get that coveted blue check verification—all for just $1 a month!

Source link

Share
What's your thought on the article, write a comment
0 Comments
×

Sign In to perform this Activity

Sign in
×

Account Frozen

Your account is frozen. You can still view content but cannot interact with it.

Please go to your settings to update your account status.

Open Profile Settings

Ads

  • Original Billionaire128 Old School Bucket Hat

    $ 28.50
  • Billionaire128 Liquid Gold Flip-Flops

    $ 18.00
  • Original Billionaire128 Fanny Pack

    $ 35.00
  • News Social

    • Facebook
    • Twitter
    • Facebook
    • Twitter
    Copyright © 2024 Billionaire Club Co LLC. All rights reserved