我一直在尝试使用Quartz上下文显示文本,但无论我尝试过什么,我只是没有运气让文本显示(但我可以显示各种其他Quartz对象) 。任何人都知道我可能会做错什么?如何在iPhone上使用Quartz显示文本?
例如:
-(void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSelectFont(context, "Arial", 24, kCGEncodingFontSpecific);
CGContextSetTextPosition(context,80,80);
CGContextShowText(context, "hello", 6);
//not even this works
CGContextShowTextAtPoint(context, 1,1, "hello", 6);
}
它应该是@“Sample Text”,因为函数需要一个NSString *。它适用于我,否则,谢谢。但是我找不到引用drawAtPoint函数,这是令人担忧的。 – CiscoIPPhone 2010-11-01 19:24:57
drawAtPoint是UIKit NSString类别的一部分 - http://developer.apple.com/library/ios/#documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html – Hunter 2011-01-07 19:19:21