Tim*_*cht 2 iphone cgpath core-text
Hej研究员,
我正在尝试将一个字母和/或多个字母转换为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);
Run Code Online (Sandbox Code Playgroud)