WordWrapLabel 1.0.0

WordWrapLabel 1.0.0

Maintained by Philipp Otto.



  • By
  • Philipp

WordWrapLabel

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

WordWrapLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'WordWrapLabel'

Description

A UILabel subclass that really makes sure that every word in the label´s text fits into one line.

The standard UILabel can automatically adjust the scale of the font size to make the whole text fit the label bounds but it doesn´t take into account the actual length of the different words of the given text. This results in words being broken up into multiple lines because they are too long to fit one line.

The WordWrapLabel finds the suitable font size to make every word of the given text fit into one line.

It also makes sure that the text fits into the whole bounds of the label when there is a line number or height restriction.

Usage

To use WordWrapLabel just import the module in your code.

import WordWrapLabel

Then use it as the custom UILabel subclass in interface builder or initialize it in code.

You can define a minimum and maximum font size which will be taken into account when determining the right font size for the label. The search will start at the maximumFontPointSize and then reduce the font size until either every word fits one line or minimumFontPointSize is reached.

maximumFontPointSize and minimumFontPointSize can be set in interface builder or in code.

wordWrapLabel.maximumFontPointSize = 25 // Default is 40
wordWrapLabel.minimumFontPointSize = 10 // Default is 1

Author

Philipp, [email protected]

License

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