iOS OC 学习手册

Swift UIBezierPath 画圆,确定开始的位置

2021-06-07  本文已影响0人  我为双鱼狂

应用场景

自定义画圆或者圆弧。

核心逻辑/代码

使用UIBezierPath(arcCenter: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool) 方法设置画圆的属性。

方法中的参数:

0 弧度的起点位置

0 弧度的起点是最右侧,上下居中的位置。

各个点的位置 (top, left, bottom, right) == (1.5 PI, 1 PI, 0.5 PI, 0 PI) - 顺时针方向

弧度不是角度

弧度时 Double.pi

示例代码

let path = UIBezierPath(arcCenter: CGPoint(x: frame.size.width/2, y: frame.size.height/2),
                            radius: frame.size.height/2 - CGFloat(borderWidth),
                            startAngle: start.toRadians(),
                            endAngle: end.toRadians(),
                            clockwise: true)
上一篇 下一篇

猜你喜欢

热点阅读