Skip to content

UIBezierPath

UIBezierPath 用于构造与绘制 2D 路径(线段、圆角矩形、圆弧等)。常见于自定义绘制或生成 CGPath

创建空路径。

static bezierPath(): UIBezierPath

Return Value:

  • UIBezierPath: 新路径实例。

从矩形创建路径。

static bezierPathWithRect(rect: any): UIBezierPath

Parameters:

NameTypeDescription
rectany矩形(如 { x, y, width, height })。

Return Value:

  • UIBezierPath: 新路径。

从椭圆(内接矩形)创建路径。

static bezierPathWithOvalInRect(rect: any): UIBezierPath

Parameters:

NameTypeDescription
rectany外接矩形。

Return Value:

  • UIBezierPath: 新路径。

从圆角矩形创建路径(四角同半径)。

static bezierPathWithRoundedRectCornerRadius(rect: any, cornerRadius: number): UIBezierPath

Parameters:

NameTypeDescription
rectany矩形。
cornerRadiusnumber圆角半径。

Return Value:

  • UIBezierPath: 新路径。

bezierPathWithRoundedRectByRoundingCornersCornerRadii

Section titled “bezierPathWithRoundedRectByRoundingCornersCornerRadii”

从圆角矩形创建路径(指定角与半径)。

static bezierPathWithRoundedRectByRoundingCornersCornerRadii(rect: any, corners: number, cornerRadii: any): UIBezierPath

Parameters:

NameTypeDescription
rectany矩形。
cornersnumber要圆角的角(位掩码)。
cornerRadiiany圆角尺寸(如 { width, height })。

Return Value:

  • UIBezierPath: 新路径。

bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise

Section titled “bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise”

从圆弧创建路径。

static bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise(center: any, radius: number, startAngle: number, endAngle: number, clockwise: boolean): UIBezierPath

Parameters:

NameTypeDescription
centerany圆心(如 { x, y })。
radiusnumber半径。
startAnglenumber起始角度(弧度)。
endAnglenumber结束角度(弧度)。
clockwiseboolean是否顺时针。

Return Value:

  • UIBezierPath: 新路径。

从 CGPath 创建路径。

static bezierPathWithCGPath(CGPath: any): UIBezierPath

Parameters:

NameTypeDescription
CGPathany已有 CGPath。

Return Value:

  • UIBezierPath: 新路径。

UIBezierPath 的实例方法(如 moveTo/lineTo/append/closePath、fill/stroke、变换、命中测试等)较多,且组合方式灵活。建议通过站内搜索你关心的方法名来快速定位。

  • 具体绘制/变换/填充/描边等方法较多,建议用站内搜索成员名。
头文件 API 清单

正在加载…

协议:,来源: