NSString 的分类,用于返回一个使用 Core Text 的您选择的字体的 UIBezierPath。您还需要将 Core Text 框架添加到您的项目中。
然后您可以创建这样的精美效果
使用这个分类非常简单
// Obtain a string with your desired character in it
NSString *test = @"4";
// Create the font you wish to use
UIFont *font = [UIFont systemFontOfSize:100];
// Get the path
UIBezierPath *glyphPath = [test bezierPathWithFont:font];
然后您可以根据需要将路径用于任何绘图代码
[[UIColor whiteColor] set];
[glyphPath fill];