UIKit.NSTextContainer Class
Models the geometric layout of a page in Text Kit.

See Also: NSTextContainer Members

Syntax

[Foundation.Register("NSTextContainer", true)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_7_0)]
public class NSTextContainer : Foundation.NSObject, Foundation.INSCoding, INSTextLayoutOrientationProvider, IDisposable

Remarks

iOS 7 introduced "Text Kit," a broad set of APIs and modifications of existing classes, built on CoreText, that greatly expands the typographical flexibility of iOS.

A UIKit.NSLayoutManager maintains a list of one or more UIKit.NSTextContainers in its NSLayoutManager.TextContainers property. The UIKit.NSLayoutManager lays out the text through these UIKit.NSTextContainers sequentially. Typically, each container will be handed to a UIKit.UITextView which will be laid out on the display surface sequentially. For text to flow from one UIKit.UITextView to another, the first UIKit.UITextView's UITextView.ScrollEnabled property must be set to false.

The following example shows text laid out in a two-column format.

C# Example

var storage = new NSTextStorage();
storage.SetString(attributedString);

var layoutManager = new NSLayoutManager();
storage.AddLayoutManager(layoutManager);
//NSTextContainer defines a logical block (page, column)
var leftHandContainer = new NSTextContainer(size);
layoutManager.AddTextContainer(leftHandContainer);

//Column 1
var leftHandView = new UITextView(new RectangleF(new PointF(padding, padding), new SizeF(UIScreen.MainScreen.Bounds.Width / 2 - padding * 2, UIScreen.MainScreen.Bounds.Height - padding * 2)), leftHandContainer);
leftHandView.BackgroundColor = UIColor.Green;
leftHandView.ScrollEnabled = false;
AddSubview(leftHandView);

//Column 2
var rightHandContainer = new NSTextContainer(size);
layoutManager.AddTextContainer(rightHandContainer);
var rightHandView = new UITextView(new RectangleF(new PointF(padding * 2 + size.Width, padding), size), rightHandContainer);
rightHandView.BackgroundColor = UIColor.Red;
AddSubview(rightHandView);         
          

The preceding diagram illustrates the objects directly involved in the two-column layout. The UIKit.NSTextStorage is the responsibility of some external model class and the two-column user-interface is specified by a custom UIKit.UIView (TwoColumnView).

A UIKit.NSTextContainer contains an array of zero or more UIKit.UIBezierPath objects in its NSTextContainer.ExclusionPaths property. Text will not be placed within these paths.

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0