Xcode 11 Beta 中的字体样式更改问题
Font style gets changed issue in Xcode 11 Beta
- 在
Xcode 11 Beta
中创建新项目或打开现有项目。
- 用
Plain
文本创建 UILabel
并保持系统字体为 Regular 样式。
- 将文本类型更改为
Attributed
字符串并检查字体样式,似乎它随着不同的字体样式而变化并且不保持相同。
PS:在 Xcode 10
工作正常。
As per Apple's official document https://developer.apple.com/fonts/
SF Pro:
This sans-serif typeface is the system font for iOS, macOS, and tvOS,
and includes a rounded variant. It provides a consistent, legible, and
friendly typographic voice.
SF Compact:
This sans-serif typeface is the system font for watchOS,
and includes a rounded variant. It suits a wide range of content and
is easily legible in a variety of contexts.
所以我们需要下载并安装SF Pro字体并设置UILabel
属性字符串字体样式为SF Pro Text Regular 18.0
以保持与Plain相同的字体样式文字有。
希望对您有所帮助!
干杯!
看起来是从 iOS13 和 XCode 11 开始,Apple 将属性字符串的系统字体更改为这种新的、衬线、类似 Times 的字体:(
我不确定这是故意的还是 iOS 中的错误。我做了一个丑陋的解决方法来处理这个问题:
UIFont *font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
if (@available(iOS 13, *)) {
font = [UIFont fontWithName:@"SFUI-Regular" size:[UIFont systemFontSize]];
}
- 在
Xcode 11 Beta
中创建新项目或打开现有项目。 - 用
Plain
文本创建UILabel
并保持系统字体为 Regular 样式。
- 将文本类型更改为
Attributed
字符串并检查字体样式,似乎它随着不同的字体样式而变化并且不保持相同。
PS:在 Xcode 10
工作正常。
As per Apple's official document https://developer.apple.com/fonts/
SF Pro:
This sans-serif typeface is the system font for iOS, macOS, and tvOS, and includes a rounded variant. It provides a consistent, legible, and friendly typographic voice.
SF Compact:
This sans-serif typeface is the system font for watchOS, and includes a rounded variant. It suits a wide range of content and is easily legible in a variety of contexts.
所以我们需要下载并安装SF Pro字体并设置UILabel
属性字符串字体样式为SF Pro Text Regular 18.0
以保持与Plain相同的字体样式文字有。
希望对您有所帮助!
干杯!
看起来是从 iOS13 和 XCode 11 开始,Apple 将属性字符串的系统字体更改为这种新的、衬线、类似 Times 的字体:(
我不确定这是故意的还是 iOS 中的错误。我做了一个丑陋的解决方法来处理这个问题:
UIFont *font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
if (@available(iOS 13, *)) {
font = [UIFont fontWithName:@"SFUI-Regular" size:[UIFont systemFontSize]];
}