绘制三角

131 阅读1分钟

绘制三角

CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, **self**.bgView.backgroundColor.CGColor);

    CGFloat rectWidth = CGRectGetWidth(rect);

    CGFloat rectHeight = CGRectGetHeight(rect);

    UIBezierPath *arrowPath = [UIBezierPath bezierPath];

    CGPoint centerPoint = CGPointMake(rectWidth / 2 , rectHeight);

    CGPoint leftPoint = CGPointMake(rectWidth / 2 - 5 , rectHeight- 5);

    CGPoint rightPoint = CGPointMake(rectWidth / 2 + 5 , rectHeight - 5);

    [arrowPath moveToPoint:centerPoint];

    [arrowPath addLineToPoint:leftPoint];

    [arrowPath addLineToPoint:rightPoint];

    [arrowPath closePath];

    CGContextAddPath(context, arrowPath.CGPath);

    CGContextClosePath(context);

    CGContextDrawPath(context, kCGPathFill);