2011-05-19 140 views
0

我试图创建一个UIView,它将充当一个圆形的TextView。我可以在iOS 4.2+上做到这一点,但在4.0 & 4.1上,CTFramesetterCreateFrame下面的调用返回nil。有什么想法吗?CTFramesetterCreateFrame返回零

- (void)drawRect:(CGRect)rect{ 
[super drawRect:rect]; 
CGContextRef context = UIGraphicsGetCurrentContext(); 
CGContextSetTextMatrix(context, CGAffineTransformIdentity); 
CGContextTranslateCTM(context, 0, self.bounds.size.height); 
CGContextScaleCTM(context, 1.0, -1.0); 

CGMutablePathRef path = CGPathCreateMutable(); 
CGPathAddEllipseInRect(path, NULL, rect); 

CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attrString); 
CTFrameRef theFrame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, [attrString length]), path, NULL); 
CTFrameDraw(theFrame, context); 
CGPathRelease(path); 
CFRelease(theFrame); 
CFRelease(framesetter); 
} 

回答

2

看起来这是一个iOS问题 - 在iOS上,您只能使用矩形作为路径。你正在添加一个椭圆。