1
我想在圓上畫一條直線(截取圓的圓弧),就像在圖片中一樣。如何繪製垂直於圓弧的直線(Core Graphics)?
我使用這個代碼來繪製圓
let center = CGPoint(x: bounds.width/2, y: bounds.height/2)
let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: Conversion.degreesToRadians(value: CGFloat(0)), endAngle: Conversion.degreesToRadians(value: CGFloat(360)), clockwise: true)
path.lineWidth = 2
path.lineCapStyle = CGLineCap.square
UIColor.white.setStroke()
path.stroke()
問題如何做CoreGraphics? (通常,你甚至不會使用CoreGraphics,而是'筆畫''UIBezierPath'或者添加一個'CAShapeLayer')。或者,如何計算這些線段的起點和終點,這個問題是數學背後的問題?你知道如何畫圓圈嗎?事實上,這個問題太廣泛了。 – Rob
把你的代碼繪製圓,也從哪裏放線 –
如何確定這些線段的起點和終點? –