创build2个贝塞尔path的联合

我有两条贝塞尔path,我想组合起来组成一个联合体,这样我就可以抚摸整个外形。 就我而言,这是一个带有尾巴的语音气泡,虽然它不是一个复杂的形状,但是使用单一path创build它实际上是相当困难的。

似乎没有用于创build联合的Core Graphics API。 我错了吗?

如果我不是,有谁知道一个图书馆可以处理这个? 我searchGitHub无济于事。

UIBezierPath这样做,如果你正在处理封闭的形状。

UIBezierPath *firstPath = [UIBezierPath bezierPath]; // build your path UIBezierPath *secondPath = [UIBezierPath bezierPath]; // build your path [firstPath appendPath:secondPath]; 

在Swift 3:Beizerpath可以通过以下方式组合:

  override func draw(_ rect: CGRect) { super.draw(rect) UIColor.black.setStroke() UIColor.red.setFill() let currentContext = UIGraphicsGetCurrentContext() currentContext?.saveGState() let path = drawTopView() path.lineWidth = 5.0 path.fill() path.stroke() let middlepath = drawMiddleView() middlepath.lineWidth = 2.0 middlepath.fill() middlepath.stroke() path.append(middlepath) currentContext?.restoreGState() }