Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This category implements some basic methods to modify the dimensions of a given UILabel

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 ESAdjustableLabel.xcodeproj
Octocat-spinner-32 ESAdjustableLabel
Octocat-spinner-32 Readme.md
Readme.md

ESAdjustable Label Category

Adjusting the size of a UILabel is a pain in the back. This category provides a couple of simple methods to make this process less painful:

// Generic method. If minSize is set to CGSizeZero then
// it is ignored
// =====================================================
- (void)adjustLabelToMaximumSize:(CGSize)maxSize 
                     minimumSize:(CGSize)minSize 
                 minimumFontSize:(int)minFontSize;

// Adjust label using only the maximum size and the 
// font size as constraints
// =====================================================
- (void)adjustLabelToMaximumSize:(CGSize)maxSize 
                 minimumFontSize:(int)minFontSize;

// Adjust the size of the label using only the font
// size as a constraint (the maximum size will be
// calculated automatically based on the screen size)
// =====================================================
- (void)adjustLabelSizeWithMinimumFontSize:(int)minFontSize;

// Adjust label without any constraints (the maximum 
// size will be calculated automatically based on the
// screen size)
// =====================================================
- (void)adjustLabel;

This repo includes a sample demo that illustrates how to use this category.

How to use it in your projects

  1. Copy the two category files below into your project
    • UILabel+ESAdjustableLabel.h
    • UILabel+ESAdjustableLabel.m
  2. Add the following line of code in the header file of the class where the UILabel you need to modify its size is located:
#import "UILabel+ESAdjustableLabel.h"

Happy hacking ;)

-Edgar

Something went wrong with that request. Please try again.