求教显示文本问题

cjc8279 2008-09-19 05:15:55
我调用了如下方法

- (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

}

界面上显示不出文本来,请问是啥原因呢?
谢谢~
...全文
112 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruiteascjc 2008-09-22
  • 打赏
  • 举报
回复
可能找不到字体"Times-Bold"
cjc8279 2008-09-19
  • 打赏
  • 举报
回复
补充:我是参考了以下的说明,但不知道为何不行。http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_text/chapter_18_section_4.html

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧