从vc移植到objective-c.感觉不错.分享之..
-(void)drawInContext:(CGContextRef)context{
CGContextSetRGBStrokeColor(context,1.0, 0.0,0.0, 1.0);
CGPoint m_One = CGPointMake(40.0,30.0);
CGPoint m_Two = CGPointMake(280.0,130.0);
double slopy , cosy , siny;
double Par =20.0; //length of Arrow (>)
slopy = atan2( ( m_One.y - m_Two.y ),
( m_One.x - m_Two.x ) );
cosy = cos( slopy );
siny = sin( slopy );//need math.h for these functions
CGContextMoveToPoint(context, m_Two.x, m_Two.y);
CGContextAddLineToPoint( context,m_Two.x + ( Par * cosy - ( Par /2.0 * siny ) ),
m_Two.y + ( Par * siny + ( Par /2.0 * cosy ) ) );
CGContextMoveToPoint( context,m_Two.x + ( Par * cosy + Par /2.0 * siny ),
m_Two.y - ( Par /2.0 * cosy - Par * siny ) );
CGContextAddLineToPoint(context, m_Two.x, m_Two.y);
CGContextSetLineWidth(context,2.0);
CGContextStrokePath(context);
}