Path
使用Path可以绘制图形
1 | struct Bodge: View { |
GeometryReader
GeometryReader让我们能够获取到父view提供的建议的size,该数据保存在GeometryProxy中,GeometryProxy提供了一个frame(in:)
函数,可以让我们分别获取到该view相对于.global
、.local
或者.name
的size。
1 | struct BadgeBackgroundView: View { |
GeometryProxy
1 | public struct GeometryProxy { |
使用.coordinateSpace(name: "ScrollViewSpace")
自定义坐标空间
示例
1 | struct CarouselView: View { |
Gradient渐变
LinearGradient
、AngularGradient
和RadialGradient
可以生成渐变色。
1 | LinearGradient(gradient: |
ZStack
ZStack
可以把组件视图堆叠在一起。