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

See Also: NSTextContainer Members

Syntax

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

Remarks

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

A MonoTouch.UIKit.NSLayoutManager maintains a list of one or more MonoTouch.UIKit.NSTextContainers in its NSLayoutManager.TextContainers property. The MonoTouch.UIKit.NSLayoutManager lays out the text through these MonoTouch.UIKit.NSTextContainers sequentially. Typically, each container will be handed to a MonoTouch.UIKit.UITextView which will be laid out on the display surface sequentially. For text to flow from one MonoTouch.UIKit.UITextView to another, the first MonoTouch.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 MonoTouch.UIKit.NSTextStorage is the responsibility of some external model class and the two-column user-interface is specified by a custom MonoTouch.UIKit.UIView (TwoColumnView).

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

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0