Search code examples
swiftui-navigationlink

can't press edges of navigation link swiftui


i created a navigation link and when i press the link edges no thing happen , i need to press the text only to sent me to next view


  NavigationLink(destination: RegisterView()) 
{Text("SIGN UP")}
.foregroundColor(Color(#colorLiteral(red: 0.2549019608, green: 0.2941176471, blue: 0.3529411765, alpha: 1)))
.padding()
.frame(width: 155, height: 50, alignment: .center)
.background(Color(#colorLiteral(red: 1, green: 0.7647058824, blue: 0.2274509804, alpha: 1)))
.cornerRadius(10)

enter image description here


Solution

  • You have put modifiers on the wrong place. The solution would be ->

      NavigationLink(destination: RegisterView()) 
    {Text("SIGN UP")
    .foregroundColor(Color(#colorLiteral(red: 0.2549019608, green: 0.2941176471, blue: 0.3529411765, alpha: 1)))
    .padding()
    .frame(width: 155, height: 50, alignment: .center)
    .background(Color(#colorLiteral(red: 1, green: 0.7647058824, blue: 0.2274509804, alpha: 1)))
    .cornerRadius(10)}