Invalid frame dimension (negative or non-finite)

Viewed 810

Hey im new to this platform but swift is giving me a headache it is seeming to have a problem with the value (Infinity) although what should i put instead

                        .bold()
                        .frame(width: .infinity, height: 20, alignment: .topLeading)
                  Text(course.type)
                                .font(.system(size: 15, weight: .light))
                                .frame(width: .infinity, height: 10, alignment: .topLeading )
                        }
                        
                    }      .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)

            Button {
                openURL(URL(string: course.link)!)
                   }
        label: {
            Text("GET").bold()
                .frame(width: 35, height: 1)
              
                .padding()
                .foregroundColor(Color(.white))
                .background(Color(.orange))
          
                .cornerRadius(25)
        }
        

             
            }.frame(width: .infinity, height: .infinity)
                .padding()
2 Answers

An infinite width or height doesn't make sense. If instead you want the view to expand as much as possible, use the maxWidth and maxHeight variants instead:

.frame(maxWidth: .infinity, maxHeight: .infinity)

Try only setting a frame when you have to, and use .none instead of .infinity.

Related