试图在iOS上获得SF Pro Display Thin Italics [英] Trying to get SF Pro Display Thin Italics on iOS

查看:444
本文介绍了试图在iOS上获得SF Pro Display Thin Italics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Swift中编写一个iOS应用程序,我想使用系统字体SF Pro。但是,我似乎无法弄清楚如何在使文本斜体的同时设置字体粗细。我知道这可以通过Helvetica Neue来实现

I am writing an iOS app in Swift, and I want to use the system font, SF Pro. However, I can't seem to figure out how to set the font weight at the same time as making the text italic. I know this was possible with Helvetica Neue with

UIFont(name: "HelveticaNeue-UltraLightItalic", size: 24.0)

但是当使用系统字体时,我似乎只能做这样的一个

But when using the system font, I can only seem to do one or the other like this

UIFont.italicSystemFont(ofSize: 24)

UIFont.systemFont(ofSize: 75.0, weight: UIFontWeightThin)

我在Font Book中看过SF Pro Display Thin Italic,我知道你可以用它来编辑Sketch和Photoshop等应用程序,但是我还没有找到让iOS显示的方法。

I have seen SF Pro Display Thin Italic in Font Book, and I know you can use it in editing apps like Sketch and Photoshop, but I have yet to find a way to get iOS to display it.

推荐答案

这是一种方法:

    var fnt = UIFont.systemFont(ofSize: 75.0, weight: UIFontWeightThin)
    if let dsc = fnt.fontDescriptor.withSymbolicTraits(.traitItalic) {
        fnt = UIFont(descriptor: dsc, size: 0)
    }
    labelOne.font = fnt

这应该可以为你提供一些东西 - 比如把它变成扩展名来使它变得灵活。

That should give you something to build on - such as turning it into an extension to make it flexible.

这篇关于试图在iOS上获得SF Pro Display Thin Italics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆