【发布时间】:2011-09-16 15:46:20
【问题描述】:
Hej 研究员,
我目前正在尝试将一个字母和/或多个字母转换为 CGPathRef,以便手动将它们绘制到自定义 UIView 中。我尝试了 CoreText 和 Framesetters 的方法,包括这个小 sn-p,但它似乎不起作用....
NSAttributedString *stringToDraw = [[NSAttributedString alloc] initWithString:content
attributes:nil];
// now for the actual drawing
CGContextRef context = UIGraphicsGetCurrentContext();
// flip the coordinate system
// draw
CTFramesetterRef frameSetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)stringToDraw);
CTFrameRef frame = CTFramesetterCreateFrame(frameSetter, CFRangeMake(0, 0), NULL, NULL);
return CTFrameGetPath(frame);
【问题讨论】: