我想每 5 秒调用一次负责在屏幕上绘制文本的方法。这是我的代码
-(void) handleTimer: (NSTimer *)timer
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, currentColor.CGColor);
CGContextTranslateCTM(context, 145.0, 240.0);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSelectFont(context, "Arial", 18, kCGEncodingMacRoman);
CGContextSetCharacterSpacing(context, 1);
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
CGContextSetRGBStrokeColor(context, 0.5,0.5,1,1);
CGContextShowTextAtPoint(context, 100, 100, "01", 2);
}
但是在调用此方法 5 秒后,我收到此错误
CGContextShowTextAtPoint: invalid context
另一件事是如何显示更细的字体?