Exploring layout priorities in SwiftUI

The property that the current layout allocates space for its children.

By default, views have a priority of 0, thus distributing space equally among sibling views. However, increasing the view layout priority causes higher-priority views to shrink later when the group shrinks, and to expand faster when the group expands.

HStack {
  Text("Life is too short to wait! Start now.")
      .background(Color.pink.opacity(0.1))
      .layoutPriority(1)

  Text("Only in the darkness you can see stars.")
      .background(Color.green.opacity(0.1))
}

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/iCloudEnd/article/details/131331311