I am not sure how to update this code:
func textWidth(text: String, font: UIFont?) -> CGFloat
{
let attributes = font?.fontDescriptor.fontAttributes
return text.size(withAttributes: attributes).width
}
Swift 4 complain: Cannot convert value of type '[UIFontDescriptor.AttributeName : Any]?' to expected argument type '[NSAttributedStringKey : Any]?'
I don't know why they broke this, but it does not get automatically fixed.