UIFont(MBStringSizing) Category Reference

Declared in UIFont+MBStringSizing.h

Overview

A UIFont class extension that adds an API for performing common string measurement tasks.

Measuring whole pixels with word wrapping

– sizeString:maxWidth:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxWidth:maxHeight:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth maxHeight:(CGFloat)maxHeight

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

maxHeight

The maximum height allowed for the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxSize:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxSize:(CGSize)maxSize

Parameters

str

The text string to measure.

maxSize

The maximum size allowed for the text. If str would not fit within maxSize.width on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

Measuring fractional pixels with word wrapping

– sizeString:maxWidth:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxWidth:maxHeight:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth maxHeight:(CGFloat)maxHeight fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

maxHeight

The maximum height allowed for the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxSize:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxSize:(CGSize)maxSize fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxSize

The maximum size allowed for the text. If str would not fit within maxSize.width on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

Measuring whole pixels with a specific line break mode

– sizeString:maxWidth:lineBreakMode:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth lineBreakMode:(NSLineBreakMode)lineMode

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified line break mode.

lineMode

The line break mode to use for measuring the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxWidth:maxHeight:lineBreakMode:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth maxHeight:(CGFloat)maxHeight lineBreakMode:(NSLineBreakMode)lineMode

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified line break mode.

maxHeight

The maximum height allowed for the text.

lineMode

The line break mode to use for measuring the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxSize:lineBreakMode:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxSize:(CGSize)maxSize lineBreakMode:(NSLineBreakMode)lineMode

Parameters

str

The text string to measure.

maxSize

The maximum size allowed for the text. If str would not fit within maxSize.width on a single line, it will be wrapped according to the line break mode NSLineBreakByWordWrapping.

lineMode

The line break mode to use for measuring the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

Measuring fractional pixels with a specific line break mode

– sizeString:maxWidth:lineBreakMode:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth lineBreakMode:(NSLineBreakMode)lineMode fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified line break mode.

lineMode

The line break mode to use for measuring the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxWidth:maxHeight:lineBreakMode:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth maxHeight:(CGFloat)maxHeight lineBreakMode:(NSLineBreakMode)lineMode fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified line break mode.

maxHeight

The maximum height allowed for the text.

lineMode

The line break mode to use for measuring the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxSize:lineBreakMode:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxSize:(CGSize)maxSize lineBreakMode:(NSLineBreakMode)lineMode fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxSize

The maximum size allowed for the text. If str would not fit within maxSize.width on a single line, it may be wrapped according to the specified line break mode.

lineMode

The line break mode to use for measuring the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

Measuring whole pixels with a specific paragraph style

– sizeString:maxWidth:paragraphStyle:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth paragraphStyle:(nonnull NSParagraphStyle *)style

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified paragraph style.

style

The paragraph style for the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxWidth:maxHeight:paragraphStyle:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth maxHeight:(CGFloat)maxHeight paragraphStyle:(nonnull NSParagraphStyle *)style

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified paragraph style.

maxHeight

The maximum height allowed for the text.

style

The paragraph style for the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxSize:paragraphStyle:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxSize:(CGSize)maxSize paragraphStyle:(nonnull NSParagraphStyle *)style

Parameters

str

The text string to measure.

maxSize

The maximum size allowed for the text. If str would not fit within maxSize.width on a single line, it may be wrapped according to the specified paragraph style.

style

The paragraph style for the text.

Return Value

The size required to draw the text string, with the width and height components rounded up to the nearest integer (whole-pixel) value.

Declared In

UIFont+MBStringSizing.h

Measuring fractional pixels with a specific paragraph style

– sizeString:maxWidth:paragraphStyle:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth paragraphStyle:(nonnull NSParagraphStyle *)style fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified paragraph style.

style

The paragraph style for the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxWidth:maxHeight:paragraphStyle:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxWidth:(CGFloat)maxWidth maxHeight:(CGFloat)maxHeight paragraphStyle:(nonnull NSParagraphStyle *)style fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxWidth

The maximum width allowed for the text. If str would not fit within maxWidth on a single line, it may be wrapped according to the specified paragraph style.

maxHeight

The maximum height allowed for the text.

style

The paragraph style for the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h

– sizeString:maxSize:paragraphStyle:fractional:

Calculates the size of the bounding rectangle required to draw a given text string in the font represented by the receiver.

- (CGSize)sizeString:(nonnull NSString *)str maxSize:(CGSize)maxSize paragraphStyle:(nonnull NSParagraphStyle *)style fractional:(BOOL)allowFractionalSize

Parameters

str

The text string to measure.

maxSize

The maximum size allowed for the text. If str would not fit within maxSize.width on a single line, it may be wrapped according to the specified paragraph style.

style

The paragraph style for the text.

allowFractionalSize

If YES, the returned size may contain fractional (sub-pixel) values. If NO, the width and height components rounded up to the nearest integer (whole-pixel) value.

Return Value

The size required to draw the text string.

Declared In

UIFont+MBStringSizing.h