UIBezierPath:moveToPoint() 方法
moveToPoint() 方法开始一段新的子路径,把起点放在指定的位置。它不画线,只把当前点移过去。
语法
moveToPoint(point)参数
point
新的起点,CGPoint,单位是 pt。也可以写成普通对象 { x, y }。
返回值
无(undefined)。
异常
TypeError
point不是对象:moveToPoint needs an object with all of: x, y。x或y缺失或转不成有限数:moveToPoint is missing y, or it is not a finite number。
说明
- 调过之后
isEmpty变成false,currentPoint变成point。 - 在已经有线段的路径上再调一次,开始第二段子路径。两段之间不相连。
示例
js
const path = new UIBezierPath();
path.moveToPoint(new CGPoint(0, 60));
console.log(path.isEmpty, String(path.currentPoint));结果:控制台输出 false CGPoint(0, 60)。
对应的 iOS API
-[UIBezierPath moveToPoint:]。
参见
addLineToPoint():从当前点画直线- 路径由什么组成