UIFont error in Xcode beta 7.3 (7D162j)?

When compiling my project in the latest version of Xcode, I get the following error.

enter image description here

The line of code calling her is this:

let font = UIFont(name: "OpenSans-Semibold", size: 10.0) 

I am not sure how to fix this.

Any idea?

So here is more context:

 private lazy var view: UIView = { let view = UIView(frame: CGRectMake(0, 0, 34, 80)) let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false let font = UIFont(name: "OpenSans-Semibold", size: 10.0) label.font = font return view }() 
+5
source share
1 answer

I also had this problem. Nothing worked for me until I tried to initialize UIFont using a UIFontDescriptor. So now your code will look like this:

 private lazy var view: UIView = { let view = UIView(frame: CGRectMake(0, 0, 34, 80)) let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false let descriptor = UIFontDescriptor(name: "OpenSans-Semibold", size: 10.0) let font = UIFont(descriptor: descriptor, size: 10.0) label.font = font return view }() 

You may also need to clean and rebuild your project after this change, the Xcode compiler did not recognize the changes at the beginning.

0
source

Source: https://habr.com/ru/post/1244611/


All Articles