iphone - 如何使用 +fontWithName :size: and specify both the font family name and the specific style information for the font? 创建字体

标签 iphone ios ipad uifont

文档说:

+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize

The fully specified name of the font. This name incorporates both the font family name and the specific style information for the font.

我找到的例子只指定了一个字体名称。但我还想指定其他属性,例如中等字体粗细等。这是如何编码到名称中的?

最佳答案

参见 this answer用于命名方案。可以找到完整的字体列表(带名称)here .

例子:

[UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0];

更新

添加了 iOS 8.2 this method用于获取不同粗细的系统字体。

例子:

[UIFont systemFontOfSize:15.0 weight:UIFontWeightBold];

关于iphone - 如何使用 +fontWithName :size: and specify both the font family name and the specific style information for the font? 创建字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10400398/

相关文章:

ios - 如何从点击的位置获取 CGPoint?

iphone - UIWebView - 自动调整大小,以便不需要滚动(在 webView 本身中)

ios - 如何在 Swift 5 中断开 BLE 设备

php - SQLite通过php将数据持久保存到MySQL服务器iOS

ios - 在 iOS 上录制、修改和播放音频

ios - 具有全屏 ImageView 的启动屏幕 .XIB

iphone - 如何用动画缩放 View

ios - 如何为 Uitextfield 设置最小和最大限制?

ios - Swift角标(Badge)通知在iOS10之后贬值

iphone - iPhone 有 Queue/FIFO 数据结构吗?