求教显示文本问题
我调用了如下方法
- (void)drawRect:(CGRect)rect {
float black[4] = { 1, 1, 1, 1 };
CGContextRef ctx = UICurrentContext( );
int i;
CGContextSetFillColor(ctx, black);
CGContextFillRect(ctx, rect);
MyDrawText(ctx,rect);
}
void MyDrawText(CGContextRef myContext ,CGRect contextRect)
{
float w, h;
w = contextRect.size.width;
h = contextRect.size.height;
CGAffineTransform myTextTransform; // 2
CGContextSelectFont (myContext, // 3
"Times-Bold",
h/10,
kCGEncodingMacRoman);
CGContextSetCharacterSpacing (myContext, 10); // 4
CGContextSetTextDrawingMode (myContext, kCGTextFillStroke); // 5
CGContextSetRGBFillColor (myContext, 0, 0, 0, .5); // 6
CGContextSetRGBStrokeColor (myContext, 0, 0, 0, 1); // 7
myTextTransform = CGAffineTransformMakeRotation (45); // 8
CGContextSetTextMatrix (myContext, myTextTransform); // 9
CGContextShowTextAtPoint (myContext, 40, 50, "Quartz 2D", 9); // 10
}
界面上显示不出文本来,请问是啥原因呢?
谢谢~