Morphi (莫菲) 为 SwiftUI 提供了一些额外的 形状。
三角形
平行四边形(topLeftAngle 左上角角度)
多边形(sides 边数)
圆角多边形(sides 边数, cornerRadius 圆角半径)
心形
月牙形(angle 角度)
加号(width 宽度)
星形(points 角数)
波浪形(isUp 向上/向下, width 宽度, offset 偏移量)
超椭圆(n 参数 n)
水滴形
环形(radius 半径)
(配合 FillStyle
使用,且 eoFill
属性设置为 true
时使用)齿轮形(radius 半径, cogs 齿数)
(配合 FillStyle
使用,且 eoFill
属性设置为 true
时使用)像其他任何形状一样,只需初始化它即可。
Heart().fill(Color.red).frame(width: 100, height: 100)
aView.clipShape(Drop())
// or using static member
aView.clipShape(.drop)
你甚至可以在另一个形状上使用它。
Polygon(sides: 6).fill(Color.red).clipShape(.drop)
对于使用 UIBezierPath
的 UIKit
版本,请参考 IBAnimatable 框架