What's with Constraints in SwiftUI?

前端 未结 3 1262
醉话见心
醉话见心 2021-01-01 09:22

What is happening now with constraints in SwiftUI? Do View types adapt automatically for bigger devices etc. or what should we have to do

3条回答
  •  臣服心动
    2021-01-01 10:02

    Constraints are very well gone, which is great, but there is something called .padding(), which can do some sort of constraint look by putting it on the left side with something like leading parameters which make an image go to the side of a view

    struct ContentView: View {
       var body: some View {
          Image("x")
             .padding(.leading)
     
            
        }
    }
    
    struct ContentView_Previews: PreviewProvider {
        static var previews: some View {
            ContentView()
        }
    }
    
    

提交回复
热议问题