赫赫小伙伴们,
我目前正在尝试将一个字母和/或多个字母转换为 CGPathRef,以便手动将它们绘制到自定义 UIView 中。我尝试了 CoreText 和 Framesetters 的方法,包括这个小片段,但它似乎不起作用......
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);