如圖所示,紅色的矩形表示一條
linePath
的終點,其中藍色的點表示路徑終點的座標,矩形的高表示寬度:linePath.lineWidth
。當
linePath.CGLingCap = .Butt
時,linePath
延伸到藍色點表示的終點就不再繼續延伸。當
linePath.CGLingCap = .Round
時,linePath
延伸到藍色點表示的終點后,在終點以linePath.lineWidth / 2
為半徑,以終點為圓心畫一個圓。當
linePath.CGLingCap = .Square
時,linePath
延伸到藍色點表示的終點后,在終點以linePath.lineWidth
為邊長,以終點為中心畫一個正方形。實際上終點的圓和正方形也是紅色的,只不過這里為了顯示區域,我畫了一個空心的圓和正方形。