FontFit scales the font
size of a text element (i.e. UILabel
or UITextView
) to fill it's container.
FontFit is the missing inverse of sizeToFit()
. The FontFit
extensions are a more detailed implementation of UILabel's adjustsFontSizeToFitWidth which only reduces font size.
Note: A full example use case can be found in the Example project.
let label = UILabel(frame: ...)
// Increase font to fill the label's frame.
label.fitTextToBounds()
let label = UILabel(frame: ...)
// Increase font to fill the label's frame, attempting to distribute onto, at most, 2 lines.
label.fitText(maxLines: 2)
FontFit is available under the MIT license. See the LICENSE file for more info.