ios - iPhone - 将 CTFont 转换为 UIFont?

标签 ios objective-c iphone uifont ctfont

我试图在不丢失任何样式和属性的情况下将 CTFont 转换为 UIFont,例如:

  • 字体名称
  • 字体大小
  • 字体颜色
  • 下划线
  • 粗体
  • 斜体
  • 等等

最佳答案

CTFontRef ctFont = ...;
NSString *fontName = [(NSString *)CTFontCopyName(ctFont, kCTFontPostScriptNameKey) autorelease];
CGFloat fontSize = CTFontGetSize(ctFont);
UIFont *font = [UIFont fontWithName:fontName size:fontSize];

颜色和下划线不是字体的属性。粗体和斜体是字体名称的一部分。

关于ios - iPhone - 将 CTFont 转换为 UIFont?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6714858/

相关文章:

ios - 使用 if 语句取消隐藏 UIButton

ios - 画三角形 iOS

objective-c - 将filteredArrayUsingPredicate应用于多维NSMutableArray的特定列

iphone - Reverse facetime 摄像头是倒置的

iphone - ios:在 UIButton 中以编程方式编辑的内容居中

iphone - iOS:Foursquare 喊叫或创建事件

ios - 使用 GCD 异步加载指向服务器上图像的本地 JSON 文件

ios - 将 localizable.strings 提交到存储库

ios - 如何在 Xcode 中加速 iPhone 模拟器

ios - UISearchBar 属性