此包添加了圆角梯形 (RoundedTrapezoid) 和梯形 (Trapezoid) 形状到 SwiftUI 中。
圆角梯形具有以下属性
cornerRadius: Determines the roundness of the corners.
edgeRatio: Determines the width of the top or right edge compared to the bottom or left edge (respectively) of the trapezoid.
Cannot be less than 0.
< 1 results in top or right edge shorter than bottom or left edge.
> 1 results in top or right edge longer than bottom or left edge.
flexibleEdge: Determines which base is "flexible."
Options are .top (default), .right, .bottom, .left
The flexible edge is the edge which will grow or shrink based on the edgeRatio; and be offset by the edgeOffset.
edgeOffset: Determines how acute the trapezoid is.
Defaults to 0 for isosceles trapezoid.
圆角梯形可以用以下方式初始化
// Defaults cornerRadius to 10, edgeRatio to 0.65, flexibleEdge to .top, edgeOffset to 0.
RoundedTrapezoid()
// Provide the cornerRadius. Defaults edgeRatio to 0.65, flexibleEdge to .top, edgeOffset to 0.
RoundedTrapezoid(cornerRadius: Double)
// Provide the cornerRadius and edgeRatio. Defaults flexibleEdge to .top, edgeOffset is set to 0.
RoundedTrapezoid(cornerRadius: Double, edgeRatio: Double)
// Provide cornerRadius and any of the other 3 properties in any combination. The defaults are as above. You can provide settings for all or some.
RoundedTrapezoid(cornerRadius: Double, edgeRatio: Double, flexibleEdge: FlexibleEdge, edgeOffset: Double)
除非 cornerRadius = 0,否则圆角梯形不能是钝角梯形。
梯形类似于圆角梯形,只是 cornerRadius 始终设置为 0,并且可以是钝角形状。