使用貝塞爾曲線繪制矩形或者圓形(設(shè)置矩形的圓角)的步驟:
1 獲取上下文 接受對象為CGContextRef 獲取上下文的方法UIGraphicsGetCurrentContext()
2 使用貝塞爾類繪制曲線
3 將貝塞爾曲線繪制在上下人上 CGContextAddPath(上下文對象然爆,貝塞爾曲線轉(zhuǎn)為CGPath類型)
4 設(shè)置設(shè)置描邊/填充顏色 - [顏色 setStroke]/[顏色 setFill]
5 進行描邊或填充 - CGContextFillPath(上下文對象)/CGContextStrokePath(上下文對象)