绘制三角形

CGContextRef context = UIGraphicsGetCurrentContext();

//    CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);

//    CGContextSetFillr

CGContextMoveToPoint(context, 150, 10);

CGContextAddLineToPoint(context, 150+21, 10+24);

CGContextAddLineToPoint(context, 150+42, 10);

CGContextClosePath(context);

[[UIColor blackColor] setStroke];//描边的颜色

[[UIColor redColor] setFill];//填充颜色

CGContextDrawPath(context, kCGPathFillStroke);

                                              kCGPathFill    无描边

                                              kCGPathFill    只有边

你可能感兴趣的:(绘制三角形)