//An opaque type that represents a Quartz 2D drawing environment. 一个不透明类型的Quartz 2D绘画环境,相当于一个画布,你可以在上面任意绘画
CGContextRef context = UIGraphicsGetCurrentContext();
//画三角形->坐标点
CGPoint sPoints[3];
CGFloat _arrowOffset = 50;
sPoints[0] = CGPointMake(_arrowOffset, 0);//坐标1
sPoints[1] = CGPointMake(_arrowOffset - 48, 48);//坐标2
sPoints[2] = CGPointMake(_arrowOffset + 48, 48);//坐标3
if (_directionType == DirectionUp) {
sPoints[0] = CGPointMake(_arrowOffset, rect.size.height);//坐标1
sPoints[1] = CGPointMake(_arrowOffset - 8, rect.size.height - 8);//坐标2
sPoints[2] = CGPointMake(_arrowOffset + 8, rect.size.height - 8);//坐标3
}
//添加线
CGContextAddLines(context, sPoints, 3);
//填充色
float r = [@"205" floatValue] / 255.0;
float g = [@"155" floatValue] / 255.0;
float b = [@"105" floatValue] / 255.0;
CGContextSetFillColorWithColor(context, [UIColor yellowColor].CGColor);
//画线笔颜色
CGContextSetRGBStrokeColor(context,r, g, b,1.0);
//封闭起来连成图形
CGContextClosePath(context);
//根据坐标绘制路径
CGContextDrawPath(context, kCGPathFillStroke);