0
我有3個UIBezierPath,有2個圓圈,一行從1個圓圈的中心到另一個,它看起來像是底部的圖片。我想隱藏像頂部圖片一樣的圓圈內部分。有沒有簡單的方法來做到這一點?隱藏UIBezierPath的一部分
我的策略是從中心畫出一條看不見的線,然後從兩個圓的圓周畫一條黑線,因爲我知道斜坡等,但看起來工作太多了。
private func pathForBoxCircle1() -> UIBezierPath {
let circlePath = UIBezierPath(arcCenter:circle1BoxCurrentCenter, radius: 25, startAngle: 0.0, endAngle: CGFloat(2*M_PI), clockwise: false)
//circlePath.fill()
pathBoxCircle1Global = circlePath
return circlePath
}
private func pathForBoxCircle2() -> UIBezierPath {
let circlePath = UIBezierPath(arcCenter:circle2BoxCurrentCenter, radius: 25, startAngle: 0.0, endAngle: CGFloat(2*M_PI), clockwise: false)
//circlePath.fill()
pathBoxCircle2Global = circlePath
return circlePath
}
private func pathForHorizonLine() -> UIBezierPath {
let path = UIBezierPath()
path.move(to: circle1BoxCurrentCenter)
path.addLine(to: circle2BoxCurrentCenter)
path.lineWidth = 5.0
//pathHorizonLineGlobal = path
return path
}
override func draw(_ rect: CGRect) {
pathForBoxCircle1().stroke()
pathForBoxCircle2().stroke() // same as stroke()
pathForHorizonLine().stroke()
}
填充圓圈的顏色? – HMHero
@HHHero我想圈出來看看 – bakalolo
你可以顯示你的代碼來繪製路徑嗎?你能不能從圓圈的最右邊畫線到另一個圓圈的最左邊部分? – Ali