【发布时间】:2011-07-26 07:33:16
【问题描述】:
我正在 iphone 中构建一个应用程序,我需要绘制一个 7 位段显示,它将显示用户输入的数字。我正在使用 CGPath 和 CGcontext。 我已经绘制了 7 位段作为数字时钟中的否。但是,我没有办法显示用户给定的否。要绘制一个 7 位段显示,我已经完成了..
CGContextRef context = UIGraphicsGetCurrentContext();
CGLineCap cap =kCGLineCapRound;
center = CGPointMake(120, 130.0);
CGContextSetRGBStrokeColor(context, 0.5, 0.0, 1.0, 0.5);
path = CGPathCreateMutable();
CGContextSetLineWidth(context, 08.0);
CGContextSetLineCap(context, cap);
CGPoint aOnePoint=CGPointMake(center.x ,center.y);
CGPoint aTwoPoint=CGPointMake(center.x ,center.y+30);
CGPoint points[]= {aOnePoint,aTwoPoint};
CGAffineTransform translation1 = CGAffineTransformMakeTranslation(0, 30);
CGAffineTransform translation2 = CGAffineTransformTranslate(translation1, 0, 42);
CGAffineTransform translation3 = CGAffineTransformTranslate(translation1, 42,0);
CGAffineTransform translation4 = CGAffineTransformTranslate(translation1, 42, 42);
CGAffineTransform translation7 = CGAffineTransformMakeTranslation(-270, 0);
CGAffineTransform translation5 = CGAffineTransformMakeRotation(-M_PI/2.0);
CGAffineTransform translation8 = CGAffineTransformMakeTranslation(-4, +3);
CGAffineTransform translation6 = CGAffineTransformConcat(CGAffineTransformConcat(translation7, translation5),translation8);
CGAffineTransform translation9 = CGAffineTransformTranslate(translation6, -44, 0);
CGAffineTransform translation10 = CGAffineTransformTranslate(translation6,-86, 0);
CGPathAddLines(path, &translation1 ,points,2);
CGPathAddLines(path, &translation2,points,2);
CGPathAddLines(path, &translation3 ,points,2);
CGPathAddLines(path, &translation4 ,points,2);
CGPathAddLines(path, &translation6 ,points,2);
CGPathAddLines(path, &translation9 ,points,2);
CGPathAddLines(path, &translation10 ,points,2);
CGContextBeginPath(context);
CGContextAddPath(context, path);
CGPathRelease(path);
CGContextStrokePath(context);
CGContextSaveGState(context);
CGContextClosePath(context);
任何帮助将不胜感激。
【问题讨论】:
-
您也可以使用自定义字体:dafont.com/ds-digital.font
-
但我不必使用自定义字体。
标签: iphone objective-c cocos2d-iphone