I am trying to find a non-deprecated method to size the font of a textview down so that all text fits in the textview without requiring scrolling.
The method \'sizeWithF
Swift 5+
var fontSize = Font.Size.section.rawValue
let minSize = Font.Size.large.rawValue
while fontSize > minSize {
let textViewSize = CGSize(width: textView.frame.size.width, height: textView.frame.size.height)
let size = textView.sizeThatFits(textViewSize)
if size.height <= textViewSize.height {
break
}
fontSize -= 1.0
}
textView.font = Font.primary.of(size: fontSize)