Reputation: 3101
This is my reproducible code. Problems: There is no error in my code but I can't find my TabView Label. The background was declared with .ignoresSafeArea(.all) but still doesn't fill the entire screen.
import SwiftUI
struct LibraryView: View {
var allColors: [Color] = [Color.red, Color.green, Color.blue]
var body: some View {
TabView {
ForEach(allColors, id: \.self) { color in
BookSubView(bColor: color)
.tabItem {
Text("BOOK")
.foregroundColor(color)
Image(systemName: "book")
}
}
}
.tabViewStyle(.page)
}
}
struct BookSubView: View {
var bColor: Color
var body: some View {
LinearGradient(colors: [bColor, Color.white], startPoint: .top,
endPoint: .bottom).ignoresSafeArea(.all)
}
}
Upvotes: 0
Views: 295
Reputation: 81
Use a Label inside of the .tabItem
modifier
BookSubView(bColor: color)
.tabItem {
// There are probably modifiers for Label you can use to customize to your needs
Label("Book", systemImage: "book")
}
Upvotes: 0