我需要在我的一个 iphone应用程序中绘制一个人体.任何人都可以帮助我 我正在尝试“drawInContext”,但没有想到如何绘制它 下面是我想在我的应用程序中的图像 下面是我正在尝试的代码
          我正在尝试“drawInContext”,但没有想到如何绘制它
下面是我想在我的应用程序中的图像
下面是我正在尝试的代码,它向我展示了人体的线条
- (void)drawInContext:(CGContextRef)context
{    
int lineWidth = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) ? 2 : 10;
CGContextSetLineWidth(context, lineWidth);
//At this point we have a NSArray filled with at least 1 NSValue
//NSLog(@"Number of Segments %d", _jointSkeletonSegments.count);
for (NSValue *ourPointNSValue in _jointSkeletonSegments)
{
    struct SkeletonSegment ourPoint;
    [ourPointNSValue getValue:&ourPoint];
    //Draw the lines
    [self drawLineWithCGPoint:ourPoint.startPosition
             andSecondCGPoint:ourPoint.endPosition
                  withContext:context];
    //Draw the points
    [self drawPointWithCGPoint:ourPoint.startPosition withContext:context];
    [self drawPointWithCGPoint:ourPoint.endPosition withContext:context];
}
}
- (void)drawLineWithCGPoint:(CGPoint)startPoint andSecondCGPoint:(CGPoint)endPoint withContext:(CGContextRef)context
{
//Decide what color we want
UIColor *ourColor = [UIColor greenColor];
//Draw
CGContextSaveGState(context);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetStrokeColorWithColor(context, ourColor.CGColor);
CGContextMoveToPoint(context, startPoint.x + 0.5, startPoint.y + 0.5);
CGContextAddLineToPoint(context, endPoint.x + 0.5, endPoint.y + 0.5);
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
- (void)drawPointWithCGPoint:(CGPoint)point withContext:(CGContextRef)context
{
CGRect rect = CGRectZero;
int pointSize = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) ? 10 : 20;
CGContextSaveGState(context);
//Make the new rect in the center of the coordinate.
rect = CGRectMake(point.x - pointSize/2,
                  point.y - pointSize/2,
                  pointSize,
                  pointSize);
CGContextStrokeEllipseInRect(context, rect);
CGContextFillEllipseInRect(context, rect);
CGContextRestoreGState(context);
} 
 谢谢,
Rafeeq
