0

I'm trying to turn an entire block of code in a link to another View using NavigationLink(). The problem is that when the text in those blocks reaches the end of the line, the text is aligned in the center. It's very annoying because it messes up my whole app design.

I tried everything I could think of, but I'm a beginner in the SwiftUI world. Anybody can help?

This is my code:

NavigationLink(destination: JoinView()) {
  HStack(spacing: 30) {
    VStack(alignment: .leading) {
      Text("TOO MUCH WORK?")
        .foregroundColor(Color("text_gray"))
        .font(.system(size:grayTextSize))
      Text("Join a study group")
        .font(.system(size: Title))
        .padding(.bottom, TitleBottomPad)
        .foregroundColor(Color("text_color"))
      Text("If you want to find some people to study with join a group of students now!")
        .foregroundColor(Color("text_gray"))
        .font(.system(size: grayTextSize))
    }
    .padding(-5)
    Image("join_pic")
      .resizable()
      .frame(width: 136.33, height: 91)
      .clipShape(Circle())
//      .padding(-10)
  }
}

The text that gets messed up is the one that goes "If you want to find some people to study with join a group of students now!".

Marco

ScottM
  • 7,108
  • 1
  • 25
  • 42
  • 1
    Including a screen grab of how the view is currently rendering would be useful. But from the description alone, it sounds like you might need a `.multilineTextAlignment(.leading)` modifier to be added to the long text? That’s usually the default, so it’s possible there’s a similar modifier being applied further up the view hierarchy. – ScottM May 20 '23 at 09:32

0 Answers0