ios 以编程方式将字体更改为 System Semibold
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33261212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing font programmatically to System Semibold
提问by KexAri
I'm trying to set a font programmatically. I want to use System Semibold like I'm using in the interface builder. Been looking for it on the list of fonts. Do I need to use
我正在尝试以编程方式设置字体。我想使用 System Semibold 就像我在界面构建器中使用的那样。一直在字体列表中寻找它。我是否需要使用
[myButton.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Semibold" size:13.0]]
?
?
回答by Jeff Lewis
The system font for iOS, starting in iOS 9, is "San Fransisco." To get a semibold version, you could use something along the lines of:
从 iOS 9 开始,iOS 的系统字体是“San Fransisco”。要获得半粗体版本,您可以使用以下内容:
Swift 2.2:
斯威夫特 2.2:
UIFont.systemFontOfSize(20, weight: UIFontWeightSemibold)
Swift 3.0:
斯威夫特 3.0:
UIFont.systemFont(ofSize: 20, weight: UIFontWeightSemibold)
Swift 4.0:
斯威夫特 4.0:
UIFont.systemFont(ofSize: 20, weight: .semibold)
For more information on this, see the UIFont Class Reference.
有关这方面的更多信息,请参阅UIFont 类参考。
回答by logixologist
To further assist you these are the official names of all the helvetica fonts that apple currently supports as taken directly from the Apple website: https://support.apple.com/en-us/HT202771
为了进一步帮助您,这些是 Apple 当前支持的所有 Helvetica 字体的官方名称,直接取自 Apple 网站:https: //support.apple.com/en-us/HT202771
Helvetica
Helvetica Bold
Helvetica Bold Oblique
Helvetica Light
Helvetica Light Oblique
Helvetica Neue
Helvetica Neue Bold
Helvetica Neue Bold Italic
Helvetica Neue Condensed Black
Helvetica Neue Condensed Bold
Helvetica Neue Italic
Helvetica Neue Light
Helvetica Neue Light Italic
Helvetica Neue Medium
Helvetica Neue Medium Italic
Helvetica Neue Thin
Helvetica Neue Thin Italic
Helvetica Neue UltraLight
Helvetica Neue UltraLight Italic
Helvetica Oblique
回答by Anshad Rasheed
I think there is no default font with name Helvetica-Semibold
you can add custom font to your projects for reference stack link 1stack link 2
我认为没有带名称的默认字体,Helvetica-Semibold
您可以将自定义字体添加到您的项目中以供参考 堆栈链接 1堆栈链接 2