How to move title from left to right

Hey, Want to move the title from left to right

struct HomeView: View {
  var body: some View {
    NavigationView {
      ZStack {
        LinearGradient(gradient: /*@START_MENU_TOKEN@*/Gradient(colors: [Color.red, Color.blue])/*@END_MENU_TOKEN@*/, startPoint: /*@START_MENU_TOKEN@*/.leading/*@END_MENU_TOKEN@*/, endPoint: /*@START_MENU_TOKEN@*/.trailing/*@END_MENU_TOKEN@*/)
      }
      .navigationTitle("בית")
      .edgesIgnoringSafeArea(.all)
      .opacity(0.3)
    }
  }
}

Thanks in advance for the answers!

There are a couple of ways of doing it depending on what you want to do with the rest of the view. One way to do it would be to add a navigation bar title instead of a navigation title like this:


  var body: some View {
    NavigationView {
      ZStack {
        LinearGradient(gradient: /*@START_MENU_TOKEN@*/Gradient(colors: [Color.red, Color.blue])/*@END_MENU_TOKEN@*/, startPoint: /*@START_MENU_TOKEN@*/.leading/*@END_MENU_TOKEN@*/, endPoint: /*@START_MENU_TOKEN@*/.trailing/*@END_MENU_TOKEN@*/)
      }
      .navigationBarItems(trailing: Text("בית"))
      .navigationBarTitle(Text(""), displayMode: .inline)
      .edgesIgnoringSafeArea(.all)
      .opacity(0.3)
    }
  }
}

or you can change the environment of the navigation view so that text on the left side will show on the right side like this:

  var body: some View {
    NavigationView {
      ZStack {
        LinearGradient(gradient: /*@START_MENU_TOKEN@*/Gradient(colors: [Color.red, Color.blue])/*@END_MENU_TOKEN@*/, startPoint: /*@START_MENU_TOKEN@*/.leading/*@END_MENU_TOKEN@*/, endPoint: /*@START_MENU_TOKEN@*/.trailing/*@END_MENU_TOKEN@*/)
      }
      .navigationTitle("בית")
      .edgesIgnoringSafeArea(.all)
      .opacity(0.3)
    }.environment(\.layoutDirection, .rightToLeft)
  }
}

This method will cause all mostly everything to start on the right side though. This may be good or bad depending on what else will be in the view. Hopefully one of these options will help.

How to move title from left to right
 
 
Q