'UIFont' is not convertible to 'UIFont?'

后端 未结 3 841
花落未央
花落未央 2020-12-08 18:38

So I had updated my XCode to 7.3 today evening.

In one of my projects, I get the following error for few labels where I set the font:

\'(name: String         


        
3条回答
  •  离开以前
    2020-12-08 19:43

    I had the same issue and doing this allows me to compile again:

    let descriptor = UIFontDescriptor(name: "OpenSans-Semibold", size: 10.0)
    label.font = UIFont(descriptor: descriptor, size: 10.0)
    

    So, use the UIFontDescriptor ...

    Also doing this works for me:

    if let font = UIFont(name: "OpenSans-Semibold", size: 10) {
        label.font = font
    }
    

提交回复
热议问题