Bird
0
0

Which modifier is used to add a tab label and icon inside a TabView in SwiftUI?

easy📝 Conceptual Q2 of 15
iOS Swift - Navigation
Which modifier is used to add a tab label and icon inside a TabView in SwiftUI?
A.font(.title)
B.tabItem { Label("Title", systemImage: "icon") }
C.listRowBackground(Color.blue)
D.navigationTitle("Title")
Step-by-Step Solution
Solution:
  1. Step 1: Identify the modifier for tab labels

    The .tabItem modifier is used to define the label and icon for each tab in a TabView.
  2. Step 2: Differentiate from other modifiers

    .navigationTitle sets navigation bar title, .listRowBackground styles list rows, .font changes text font, none set tab labels.
  3. Final Answer:

    .tabItem { Label("Title", systemImage: "icon") } -> Option B
  4. Quick Check:

    Tab label = .tabItem modifier [OK]
Quick Trick: Use .tabItem with Label for tab icons and titles [OK]
Common Mistakes:
  • Using .navigationTitle instead of .tabItem
  • Confusing list styling modifiers with tab labels
  • Forgetting to include systemImage in Label

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes