Open EliseevDmitry opened 4 days ago
Custom tabBarView is ready
import SwiftUI
struct CustomTabBarView: View { @State private var selectedIndex = 1
var body: some View {
ZStack {
HStack {
TabBarButton(imageName: "house", isSelected: selectedIndex == 0)
.onTapGesture {
selectedIndex = 0
}
Spacer()
TabBarButton(imageName: "bookmark", isSelected: selectedIndex == 1)
.onTapGesture {
selectedIndex = 1
}
Spacer()
TabBarButton(imageName: "bell", isSelected: selectedIndex == 2)
.onTapGesture {
selectedIndex = 2
}
Spacer()
TabBarButton(imageName: "person", isSelected: selectedIndex == 3)
.onTapGesture {
selectedIndex = 3
}
}
.padding(.horizontal, 32)
.padding(.vertical, 16)
.background(Color.white)
.clipShape(Capsule())
.shadow(color: Color.black.opacity(0.1), radius: 5, x: 0, y: 5)
Circle()
.frame(width: 70, height: 60)
.foregroundColor(.red)
.shadow(color: Color.black.opacity(0.2), radius: 5, x: 0, y: 5)
.overlay(
Image(systemName: "plus")
.font(.system(size: 24))
.foregroundColor(.black)
)
.offset(y: -35)
.onTapGesture {
// Handle center button action
}
}
.padding(.bottom, 20)
}
}
struct TabBarButton: View { let imageName: String let isSelected: Bool
var body: some View {
Image(systemName: imageName)
.font(.system(size: 24))
.foregroundColor(isSelected ? .red : .gray)
}
}
struct CustomTabBarView_Previews: PreviewProvider { static var previews: some View { CustomTabBarView() .previewLayout(.sizeThatFits) } }
Создать кастомный компонент CustomNavBarView (Components/CustomNavBarView.swift) Цвета в проект уже загружены (пользуйтесь) - Assets.xcassets/Colors