私はCGContextRef
1つの水平バーを描画するために使用しており、バーの上下にdrawInRect
メソッドを使用してテキストを表示していますNSString
。コードは次のとおりです:
CGContextRef context = UIGraphicsGetCurrentContext();//set frame for bar
CGRect frame;
frame.origin.x = prevWidth;
frame.origin.y = heightBar;
frame.size.height = heightOfBar;
frame.size.width = 10;
UIColor* color = [ColorArray objectAtIndex:i];
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextSetLineWidth(context, lineWidth);
CGContextSetStrokeColorWithColor(context, borderColor.CGColor);
CGContextFillRect(context, frame);
CGContextStrokeRect(context, frame);
[nameString drawInRect:frame1 withFont:font lineBreakMode:NSLineBreakByClipping alignment:NSTextAlignmentCenter];
2回目に電話すると、次のようなエラーが表示されます:<Error>: CGContextSetFillColorWithColor: invalid context 0x0
.Please help me.Thanking.