iOS Developer Library

Developer

UIKit Framework Reference NSLayoutManagerDelegate Protocol Reference for iOS

Options
Deployment Target:

On This Page
Language:

NSLayoutManagerDelegate

The NSLayoutManagerDelegate protocol defines the optional methods implemented by delegates of NSLayoutManager objects.

  • Informs the delegate that the given layout manager has finished laying out text in the given text container.

    Declaration

    Swift

    optional func layoutManager(_ layoutManager: NSLayoutManager, didCompleteLayoutForTextContainer textContainer: NSTextContainer?, atEnd layoutFinishedFlag: Bool)

    Objective-C

    - (void)layoutManager:(NSLayoutManager *)layoutManager didCompleteLayoutForTextContainer:(NSTextContainer *)textContainer atEnd:(BOOL)layoutFinishedFlag

    Parameters

    layoutManager

    The layout manager doing the layout.

    textContainer

    The text container in which layout is complete. If nil, if there aren’t enough containers to hold all the text; the delegate can use this information as a cue to add another text container.

    layoutFinishedFlag

    If YEStrue, layoutManager is finished laying out its text—this also means that textContainer is the final text container used by the layout manager. Delegates can use this information to show an indicator or background or to enable or disable a button that forces immediate layout of text.

    Discussion

    This message is sent whenever a text container has been filled. This method can be useful for paginating.

    Availability

    Available in iOS 7.0 and later.

  • Sent right before the layout manager invalidates layout due to the text container changing geometry.

    Declaration

    Swift

    optional func layoutManager(_ layoutManager: NSLayoutManager, textContainer textContainer: NSTextContainer, didChangeGeometryFromSize oldSize: CGSize)

    Objective-C

    - (void)layoutManager:(NSLayoutManager *)layoutManager textContainer:(NSTextContainer *)textContainer didChangeGeometryFromSize:(CGSize)oldSize

    Parameters

    layoutManager

    The layout manager invalidating layout.

    textContainer

    The text container that changed geometry.

    oldSize

    The size of the text container before it changed geometry.

    Discussion

    The delegate can react to the geometry change and perform adjustments such as recreate an exclusion path.

    Availability

    Available in iOS 7.0 and later.