補充資料

 Building Layouts with Stack Views

  • If your layout has one dominant view that defines the size of the layout, use the overlay(_:alignment:) or background(_:alignment:) view modifier on that view.
  • If you want the final view size to come from an aggregation of all the contained views, use a ZStack.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

 Making Fine Adjustments to a View’s Position

the offset(x:y:) modifier uses the parameters of x and y to represent a relative location within the view’s coordinate space.

ZStack 沒有指定 alignment,所以 Image 會在正中間(80,80)。 .offset(x: 40.0, y: -40.0) 加上這個偏移的話,就會坐落在第一象限。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Creating custom paths with SwiftUI

尖頭三角形 圓頭三角形
.stroke(.blue, lineWidth: 10) .stroke(.blue, style: StrokeStyle(lineWidth: 10, lineCap: .round, lineJoin: .round))
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

 Laying Out a Simple View

  1. The ZStack proposes a size to its child views, the Circle and Text views.
  2. The Circle expands up to the size offered, while the Text takes just enough space for the string it contains.
  3. The ZStack returns the size of its largest child view, in this case the Circle.
MessageRow的大小被HStack 決定 變成加了約束寬度的ZStack主宰者
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

How to control layout priority using layoutPriority()

All views have a layout priority of 0 by default. Raising a view’s layout priority encourages the higher priority view to shrink later.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →