System UIBarButtonItem in SwiftUI

Viewed 276

I have a settings dialog and in the NavigationBar I'd like to have as leading item a 'Cancel' and as trailing item a 'Done' button (no EditButton, the values are editable right away).

I could now add Text("Done") and provide my own translations for each supported language, but as there are already native system translations, why not using them?

For Storyboards I would do something like

let doneButton = UIBarButtonItem(barButtonSystemItem: systemItem, target: self, action: #selector(self.doneButtonAction)

How can this be done in SwiftUI?

(As UIBarButtonItem does not derive from UIView, I also cannot wrap it in a UIViewRepresentable.)

0 Answers
Related