Mac Guides | Samples

MonoMac.Foundation.NSMutableAttributedString Class

Mutable strings that can be annotated with a set of attributes.

See Also: NSMutableAttributedString

Syntax

[MonoMac.Foundation.Register("NSMutableAttributedString", true)]
public class NSMutableAttributedString : NSAttributedString

Remarks

The NSMutableAttributedString holds a mutable string that can has a series of overlapping attributes applied to ranges of the string.

>

Unlike the NSAttributedString both the contents of the string as well as the attributes applied to it can be changed after the string has been constructed.

These types typically are used to attach information to elements of the string that dictate the font and colors to use as well as rendering attributes like kerning or how to render ligatures on a specific run of code.

These classes do not dictate the meaning or behavior of the attributes on a string, they merely keep track of the attributes. The actual meaning of these attributes is interpreted by the consumer of these objects.

If you are performing multiple changes to an NSMutableAttributedString, you can optimize the performance by surrounding your changes with calls to Foundation.BeginEditing and Foundation.EndEditing. This will prevent the internal data structures to be updated on every change and delay the internal changes until the Foundation.EndEditing method is called.

Requirements

Namespace: MonoMac.Foundation
Assembly: XamMac (in XamMac.dll)
Assembly Versions: 0.0.0.0

The members of MonoMac.Foundation.NSMutableAttributedString are listed below.

See Also: NSAttributedString

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
Creates a NSMutableAttributedString from a NSAttributedString.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes when the derived class has an [Export] constructor.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.
Creates an NSMutableAttributedString from a C# string, with no attributes attached to it.
Creates an NSMutableAttributedString from a C# string and applies the specified CoreText attributes to the entire string.
Creates an NSMutableAttributedString from a C# string and applies the attributes contained in the NSDictionary to the entire string.

Public Properties

[read-only]
override
ClassHandleIntPtr. The handle for this class.

Public Methods

AddAttribute(NSString, NSObject, NSRange)
Adds an attribute and its value to the specified range of characters in the string.
AddAttributes(CTStringAttributes, NSRange)
Adds an attribute and its value to the specified range of characters in the string.
AddAttributes(NSDictionary, NSRange)
Adds the specified attributes in the dictionary to the specified range of characters in the string.
Append(NSAttributedString)
Appends an attributed string to this string.
Append(NSAttributedString, params Object[])
BeginEditing()
Marks the beginning of changes.
DeleteRange(NSRange)
Removes the characters in the specified range.
EndEditing()
Marks the end of changes.
Insert(NSAttributedString, Int32)
Inserts an attributed string into the current string.
RemoveAttribute(String, NSRange)
Removes the specified attribute from the range of characters
Replace(NSRange, NSAttributedString)
Replaces the specified range of characters with an attributed string.
Replace(NSRange, String)
Replaces the specified range of characters with an attributed string.
SetAttributes(CTStringAttributes, NSRange)
Sets the attributes for the specified ranges. Any previous attributes in that range are replaces with the new values.
SetAttributes(NSDictionary, NSRange)
Sets the attributes for the specified ranges. Any previous attributes in that range are replaces with the new values.
SetString(NSAttributedString)
Sets the contents of this NSMutableAttributedString to the value specified.