Skip to content

Dead simple Objective-C UILabel subclass that balance text horizontally across several lines so all the lines have similar length and you don't end with a screen wide UILabel where the last line has only 1 word

License

Notifications You must be signed in to change notification settings

Julioacarrettoni/DEVJACAutoBalancedLabel

Repository files navigation

DEVJACAutoBalancedLabel

Dead simple Objective-C UILabel subclass that balance text horizontally across several lines so all the lines have similar length and you don't end with a screen wide UILabel where the last line has only 1 word

FAQ

How does it work?

It's dead simple, it just overrides this method - (void)drawTextInRect:(CGRect)rect and makes the UILabel belives it is actually less wider as it is so the text is rendered in a smaller Rect balancing the number of words per line.

How does it look like?

Example 1 Example 2 Example 3

Installation?

CocoaPods

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

pod "DEVJACAutoBalancedLabel"

Manual

Just drag and drop DEVJACAutoBalancedLabel.h and DEVJACAutoBalancedLabel.mto your project

Carthage

Carthage coming soon (or never as it takes more time than copy pasting the whole code into your project)

Usage?

On IB or when creating UILabels, just make it an instance of DEVJACAutoBalancedLabel instead of `UILabel``

Swift version?

It is dead simple, just translate the code yourself! It takes more time to create the repo and push than to actually code it :P Maybe later.

License?

MIT or… do what ever you want with it but if you can mention me somewhere or at least send me a tweet saying "thanks" I will appreciate it @dev_jac

Favorite Pizza toppin?

Pepperoni

About

Dead simple Objective-C UILabel subclass that balance text horizontally across several lines so all the lines have similar length and you don't end with a screen wide UILabel where the last line has only 1 word

Resources

License

Stars

Watchers

Forks

Packages

No packages published