开发者

CTFramesetterCreateFrame returns nil

开发者 https://www.devze.com 2023-03-07 06:49 出处:网络
I\'m trying to create a UIView that will act as a circular TextView. I\'m able to do this fine on iOS 4.2+, but on 4.0 & 4.1, the call below to CTFramesetterCreateFrame is returning nil. Any thoug

I'm trying to create a UIView that will act as a circular TextView. I'm able to do this fine on iOS 4.2+, but on 4.0 & 4.1, the call below to CTFramesetterCreateFrame is returning nil. Any thoughts?

- (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);
CFR开发者_如何学Celease(theFrame);
CFRelease(framesetter);
}


Looks like this is an iOS question - on iOS, you can only use rectangles as paths. You're adding an ellipse.

0

精彩评论

暂无评论...
验证码 换一张
取 消