Skip to content

joncardasis/FontFit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChromaColorPicker 2.0

Abstract

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.

Examples

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)

License

FontFit is available under the MIT license. See the LICENSE file for more info.