Skip to content

Instantly share code, notes, and snippets.

@mattrighetti
Last active July 13, 2021 13:57
Show Gist options
  • Save mattrighetti/5fef129cd55f0218b315686766e0726e to your computer and use it in GitHub Desktop.
Save mattrighetti/5fef129cd55f0218b315686766e0726e to your computer and use it in GitHub Desktop.
This is a View extension that allows you to place other Views in the center of the NavigationView
func navigationBarItems<L, C, T>(leading: L, center: C, trailing: T) -> some View where L: View, C: View, T: View {
self.navigationBarItems(leading:
HStack{
HStack {
leading
}
.frame(width: 100, alignment: .leading)
Spacer()
HStack {
center
}
.frame(width: 130, alignment: .center)
Spacer()
HStack {
trailing
}
.frame(width: 100, alignment: .trailing)
}
.frame(width: UIScreen.main.bounds.size.width-32)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment