iPhone系统字体
iPhone 的默认系统字体名称是什么?
我想检索它以自定义 UIView
。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
iPhone 的默认系统字体名称是什么?
我想检索它以自定义 UIView
。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(12)
来自 http://www .everyipod.com/iphone-faq/iphone-who-Designed-iphone-font-used-iphone-ringtones.html
对于iOS9,它已更改为旧金山。有关详细信息,请参阅 http://developer.apple.com/fonts。
From http://www.everyipod.com/iphone-faq/iphone-who-designed-iphone-font-used-iphone-ringtones.html
For iOS9 it has changed to San Francisco. See http://developer.apple.com/fonts for more info.
如果您正在进行编程自定义,请不要对系统字体进行硬编码。使用
UIFont systemFontOfSize:
、UIFont boldSystemFontOfSize:
和UIFont italicSystemFontOfSize
(Apple 文档)。自 iOS 7 将系统字体更改为 Helvetica Neue 以来,这一点变得尤为重要。
自 iOS 9 以来,这一点变得尤其重要,iOS 9 再次将系统字体更改为 San Francisco。
If you're doing programatic customisation, don't hard code the system font. Use
UIFont systemFontOfSize:
,UIFont boldSystemFontOfSize:
andUIFont italicSystemFontOfSize
(Apple documentation).This has become especially relevant since iOS 7, which changed the system font to Helvetica Neue.
This has become super especially relevant since iOS 9, which changed the system font again to San Francisco.
afaik iPhone 默认使用“Helvetica”
< iOS 10
afaik iPhone uses "Helvetica" by default
< iOS 10
Swift
特定字体
在 Swift 中设置特定字体是这样完成的:
如果您不知道名称,您可以获取可用字体名称的列表,如下所示:
或者更详细的列表,如this:
但是系统字体随着iOS版本的不同而变化。所以最好动态获取系统字体。
系统字体
但是我们硬编码了尺寸。如果用户的眼睛不好,想要把字体调大怎么办?当然,您可以在应用程序中进行设置,让用户更改字体大小,但如果用户必须为手机上的每个应用程序单独执行此操作,这会很烦人。只需在常规设置中进行一项更改会更容易...
动态字体
啊,现在我们为 文本样式 我们正在使用。这是设置字体的推荐方法。有关详细信息,请参阅支持动态类型。
相关
Swift
Specific font
Setting a specific font in Swift is done like this:
If you don't know the name, you can get a list of the available font names like this:
Or an even more detailed list like this:
But the system font changes from version to version of iOS. So it would be better to get the system font dynamically.
System font
But we have the size hard-coded in. What if the user's eyes are bad and they want to make the font larger? Of course, you could make a setting in your app for the user to change the font size, but this would be annoying if the user had to do this separately for every single app on their phone. It would be easier to just make one change in the general settings...
Dynamic font
Ah, now we have the system font at the user's chosen size for the Text Style we are working with. This is the recommended way of setting the font. See Supporting Dynamic Type for more info on this.
Related
您始终可以使用
答案是:
最高 iOS 6
iOS 7
但您可以只使用
Helvetica Neue
You can always use
The answer is:
Up to iOS 6
iOS 7
but you can just use
Helvetica Neue
我不确定是否有一个 api 可以获取默认的系统字体名称。所以我就得到了这样的名字:
看起来很愚蠢,但它确实有效。
I'm not sure there is an api to get the default system font name. So I just get the name like this :
Looks stupid but it works.
以下是支持 iOS 7 的一些更新。它有
动态字体大小
现在。和常量列表,详细解释为此处
Here is some update for supporting iOS 7. It has
Dynamic Font Size
now.And constants list, detailed explanation is here
UIFont (UIInterface.h) 的类别 UIFontSystemFonts 提供了几种方便的预定义尺寸。
我将它用于聊天消息(标签),当我需要获取文本块的大小时它效果很好。
快乐编码!
Category UIFontSystemFonts for UIFont (UIInterface.h) provides several convenient predefined sizes.
I use it for chat messages (labels) and it work well when I need to get size of text blocks.
Happy coding!
这将为您提供系统字体,并且默认情况下应用于标签文本的默认系统字体大小。
This will give you the system font with the default system font size applied for the label texts by default.
Swift
您应该始终使用系统默认值,而不是对字体名称进行硬编码,因为 Apple 可能随时更改默认字体。
有几种不同大小(标签、按钮等)的系统默认字体(正常、粗体、斜体):
请注意,默认字体大小取决于目标视图(标签、按钮、其他)
示例:
Swift
You should always use the system defaults and not hard coding the font name because the default font could be changed by Apple at any time.
There are a couple of system default fonts(normal, bold, italic) with different sizes(label, button, others):
beaware that the default font size depends on the target view (label, button, others)
Examples:
下载所需的.ttf文件
将.ttf文件添加到复制捆绑资源下,仔细检查是否
在资源下添加 ttf 文件
在 info.pllist 中按原样添加 ttf 文件名。
现在打开字体簿,将.ttf文件添加到字体簿中,选择
信息图标,您可以在其中找到 postscript 名称。
现在在字体名称的位置给出后记名称
download required .ttf file
add the .ttf file under copy bundle resource, double check whether
the ttf file is added under resource
In info.pllist add the ttf file name as it is.
now open the font book add the .ttf file in the font book, select
information icon there you find the postscript name.
now give the postscript name in the place of font name
iOS 的默认字体是 San Francisco 。您可以参考链接了解更多信息细节
The default font for iOS is San Francisco . You can refer the link for further details