2
HEJ研究員,從文本獲取CGPath
我目前正在試圖將文字和/或他們的多重轉換爲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);