2

How can I get the ToolbarItem to bold the primaryAction? I have been able to change the color by setting the accent color on the NavigationView. Primarily looking for a SwiftUI solution but I will settle for UI Kit solution if not possible. My Code:

.toolbar {
  ToolbarItem(placement: ToolbarItemPlacement.primaryAction) {
    Button(action: { }) {
      Text("Save")
        .fontWeight(.black) // does nothing
        .bold() // does nothing
    }
  }
}

primaryAction placement is not bolded:

primaryAction placement is not bolded

principal placement is bolded by default:

principal placement is bolded by default

DarthQuack
  • 1,254
  • 3
  • 12
  • 22
Andrew Stoddart
  • 408
  • 4
  • 9

1 Answers1

9

I struggled with this one for a while too. The solution is to use .confirmationAction instead of .primaryAction. This renders in the same location but with bold text, at least for now (on iOS 14).

.toolbar {
  ToolbarItem(placement: ToolbarItemPlacement.confirmationAction) {
    Button {
      //do something
    } label: {
      Text("Save")
    }
  }
}
Kona Farry
  • 116
  • 1
  • 1