- (void)drawRect:(CGRect)rect {
CGRect frame = CGRectMake(0, kArrowHeight, self.bounds.size.width, self.bounds.size.height-kArrowHeight);
// 获取各个角落点
float xMin = CGRectGetMinX(frame);
float yMin = CGRectGetMinY(frame);
float xMax = CGRectGetMaxX(frame);
float yMax = CGRectGetMaxY(frame);
UIBezierPath *path = [UIBezierPath bezierPath];
path.lineCapStyle = kCGLineCapRound; //线条拐角
path.lineJoinStyle = kCGLineCapRound; //终点处理
// 左上 圆角构成
[path moveToPoint:CGPointMake(xMin, yMin + kCornerRadius)];
[path addQuadCurveToPoint:CGPointMake(xMin + kCornerRadius, yMin) controlPoint:CGPointMake(xMin, yMin)];
// 箭头
// 获取箭头point
CGPoint arrowPoint = CGPointMake(self.bounds.size.width - 2 *kArrowHeight, 0);
// 箭头的构成
[path addLineToPoint:CGPointMake(arrowPoint.x - kArrowRadius, yMin)];
[path addLineToPoint:arrowPoint];
[path addLineToPoint:CGPointMake(arrowPoint.x + kArrowRadius, yMin)];
// 右上 圆角构成
[path addLineToPoint:CGPointMake(xMax - kCornerRadius, yMin)];
[path addQuadCurveToPoint:CGPointMake(xMax, yMin + kCornerRadius) controlPoint:CGPointMake(xMax, yMin)];
// 右下 圆角构成
[path addLineToPoint:CGPointMake(xMax, yMax - kCornerRadius)];
[path addQuadCurveToPoint:CGPointMake(xMax - kCornerRadius, yMax) controlPoint:CGPointMake(xMax, yMax)];
// 左下 圆角构成
[path addLineToPoint:CGPointMake(xMin + kCornerRadius, yMax)];
[path addQuadCurveToPoint:CGPointMake(xMin, yMax - kCornerRadius) controlPoint:CGPointMake(xMin, yMax)];
// 填充颜色
[self.mainColor setFill];
[path fill];
[path closePath];
}