Home » iPhonetitle_li=Mac OS X » Draw arrow on QuartzCore for iOS

Draw arrow on QuartzCore for iOS

Simple drawing arrow.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- (void) drawArrowWithContext:(CGContextRef)context atPoint:(CGPoint)startPoint withSize:(CGSize)size lineWidth:(float)width arrowHeight:(float)aheight
{
    float width_wing = (size.width-width)/2;
    float main = size.height-aheight;
    CGPoint rectangle_points[] =
    {
     CGPointMake(startPoint.x + width_wing, startPoint.y + 0.0),
        CGPointMake(startPoint.x + width_wing, startPoint.y + main),
        CGPointMake(startPoint.x + 0.0, startPoint.y + main), // left point
        CGPointMake(startPoint.x + size.width/2, startPoint.y + size.height),
       
        CGPointMake(startPoint.x + size.width, startPoint.y + main), // right point
       
        CGPointMake(startPoint.x + size.width-width_wing, startPoint.y + main),
       
        CGPointMake(startPoint.x + size.width-width_wing, startPoint.y + 0.0),
        CGPointMake(startPoint.x + width_wing, startPoint.y + 0.0),
    };
   
    CGContextAddLines(context, rectangle_points, 8);
   
    CGContextFillPath(context);
}

Comments are closed.