I want to add names bellow the sf symbols, like home, menu, add new:
Like in this picture:
This is the code, using a vm machine and cant copy the code:
CodePudding user response:
You could do it like this but that is not a tab bar, here is an example on how you can do it your way, basically you would add another array with the names for the tabs and wrap the Image and the Text into a VStack
:
let tabNames = ["Profile", "Settings", etc...]
HStack {
ForEach(0..<5, id: \.self) { number in
Spacer()
Button(action: {
self.selectedIndex = number
}, label: {
VStack(spacing: 0) {
Image(systemName: icons[number])
.font(.system(size: 25, weight: .regular, design: .default))
.foregroundColor(selectedIndex == number ? .black : Color(UIColor.lightGray))
Text(tabNames[number])
font(.system(size: 25, weight: .regular, design: .default))
.foregroundColor(selectedIndex == number ? .black : Color(UIColor.lightGray))
}
})
Spacer()
}
}