2017-06-01 24 views
1

我使用這段代碼繪製使用UIBezierPath類直線如下一個圓圈:畫線的一半使用UIBezierPath

let myPath = UIBezierPath() 
    myPath.move(to: CGPoint(x:10, y:5)) 
    myPath.addLine(to: CGPoint(x:100, y:5)) 

    myPath.close() 
    UIColor.blue.set() 
    myPath.stroke() 
    myPath.fill() 
然而

,我不知道如何改變這一基本繪製在路徑中包括半圈到如下:

enter image description here

+0

嘗試addArc方法 –

回答

1

來自:addArc documentation

myPath.addArc(withCenter: CGPoint(x: 55, y: 5), 
       radius: 10, 
       startAngle: 0, 
       endAngle: CGFloat.pi, 
       clockwise: false) 

這應該給你關於你想要的圈子。您還需要將您的線路分成兩段。