我正在尝试“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 wantUIcolor *ourcolor = [UIcolor greencolor];//DrawCGContextSaveGState(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
以上是内存溢出为你收集整理的ios – 在客观c中绘制人体全部内容,希望文章能够帮你解决ios – 在客观c中绘制人体所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)