編集

次の方法で共有


NSMutableAttributedString Class

Definition

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

[Foundation.Register("NSMutableAttributedString", true)]
public class NSMutableAttributedString : Foundation.NSAttributedString
type NSMutableAttributedString = class
    inherit NSAttributedString
Inheritance
NSMutableAttributedString
Derived
Attributes

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 M:Foundation.BeginEditing() and M:Foundation.EndEditing(). This will prevent the internal data structures to be updated on every change and delay the internal changes until the M:Foundation.EndEditing() method is called.

Constructors

NSMutableAttributedString()

Default constructor that initializes a new instance of this class with no parameters.

NSMutableAttributedString(IntPtr)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

NSMutableAttributedString(NSAttributedString)

Creates a NSMutableAttributedString from a NSAttributedString.

NSMutableAttributedString(NSCoder)

A constructor that initializes the object from the data stored in the unarchiver object.

NSMutableAttributedString(NSObjectFlag)

Constructor to call on derived classes to skip initialization and merely allocate the object.

NSMutableAttributedString(String)

Creates an NSMutableAttributedString from a C# string, with no attributes attached to it.

NSMutableAttributedString(String, CTStringAttributes)

Creates an NSMutableAttributedString from a C# string and applies the specified CoreText attributes to the entire string.

NSMutableAttributedString(String, NSDictionary)

Creates an NSMutableAttributedString from a C# string and applies the attributes contained in the NSDictionary to the entire string.

NSMutableAttributedString(String, UIFont, UIColor, UIColor, UIColor, NSParagraphStyle, NSLigatureType, Single, NSUnderlineStyle, NSShadow, Single, NSUnderlineStyle)
NSMutableAttributedString(String, UIStringAttributes)

Properties

Class (Inherited from NSObject)
ClassHandle

The handle for this class.

ContainsAttachments (Inherited from NSAttributedString)
DebugDescription

A developer-meaningful description of this object.

(Inherited from NSObject)
Description

Description of the object, the Objective-C version of ToString.

(Inherited from NSObject)
Handle

Handle (pointer) to the unmanaged object representation.

(Inherited from NSObject)
IsDirectBinding (Inherited from NSObject)
IsProxy (Inherited from NSObject)
Length

The number of characters in this string.

(Inherited from NSAttributedString)
LowLevelValue

Low-level version of the Value property, returns a handle to the underlying Objective-C NSString.

(Inherited from NSAttributedString)
MutableString
RetainCount

Returns the current Objective-C retain count for the object.

(Inherited from NSObject)
Self (Inherited from NSObject)
Size (Inherited from NSAttributedString)
Superclass (Inherited from NSObject)
SuperHandle

Handle used to represent the methods in the base class for this NSObject.

(Inherited from NSObject)
Value

Contents of the object as a string.

(Inherited from NSAttributedString)
WritableTypeIdentifiersForItemProvider (Inherited from NSAttributedString)
Zone (Inherited from NSObject)

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.

AddAttributes(NSStringAttributes, NSRange)
AddAttributes(UIStringAttributes, NSRange)
AddObserver(NSObject, NSString, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using NSString keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSObject, String, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using string keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSString, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
AddObserver(String, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
Append(NSAttributedString)

Appends an attributed string to this string.

Append(NSAttributedString, Object[])
AwakeFromNib()

Called after the object has been loaded from the nib file. Overriders must call base.AwakeFromNib().

(Inherited from NSObject)
BeginEditing()

Marks the beginning of changes.

BeginInvokeOnMainThread(Action) (Inherited from NSObject)
BeginInvokeOnMainThread(Selector, NSObject)

Invokes asynchrously the specified code on the main UI thread.

(Inherited from NSObject)
Bind(NSString, NSObject, String, NSDictionary) (Inherited from NSObject)
Bind(String, NSObject, String, NSDictionary)
Obsolete.
(Inherited from NSObject)
BindingInfo(String)
Obsolete.
(Inherited from NSObject)
BindingOptionDescriptions(String)
Obsolete.
(Inherited from NSObject)
BindingValueClass(String)
Obsolete.
(Inherited from NSObject)
BoundingRectWithSize(CGSize, NSStringDrawingOptions) (Inherited from NSAttributedString)
CommitEditing() (Inherited from NSObject)
CommitEditing(NSObject, Selector, IntPtr) (Inherited from NSObject)
ConformsToProtocol(IntPtr)

Invoked to determine if this object implements the specified protocol.

(Inherited from NSObject)
ContainsAttachmentsInRange(NSRange) (Inherited from NSAttributedString)
Copy()

Performs a copy of the underlying Objective-C object.

(Inherited from NSObject)
Copy(NSZone)

Performs a copy of the underlying Objective-C object.

(Inherited from NSAttributedString)
DangerousAutorelease() (Inherited from NSObject)
DangerousRelease() (Inherited from NSObject)
DangerousRetain() (Inherited from NSObject)
DeleteRange(NSRange)

Removes the characters in the specified range.

DidChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates a change occurred to the indexes for a to-many relationship.

(Inherited from NSObject)
DidChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
DidChangeValue(String)

Indicates that a change occurred on the specified key.

(Inherited from NSObject)
Dispose()

Releases the resources used by the NSObject object.

(Inherited from NSObject)
Dispose(Boolean)

Releases the resources used by the NSObject object.

(Inherited from NSObject)
DoesNotRecognizeSelector(Selector)

Indicates that this object does not recognize the specified selector.

(Inherited from NSObject)
DoubleClick(nuint) (Inherited from NSAttributedString)
DrawString(CGPoint)

Draws the string at the specified point.

(Inherited from NSAttributedString)
DrawString(CGRect) (Inherited from NSAttributedString)
DrawString(CGRect, NSStringDrawingOptions) (Inherited from NSAttributedString)
DrawString(CGRect, NSStringDrawingOptions, NSStringDrawingContext) (Inherited from NSAttributedString)
EncodeTo(NSCoder)

Encodes the state of the object on the provided encoder

(Inherited from NSAttributedString)
EndEditing()

Marks the end of changes.

EnumerateAttribute(NSString, NSRange, NSAttributedStringEnumeration, NSAttributedStringCallback)

Applies the callback to the specified attribute in the specified range.

(Inherited from NSAttributedString)
EnumerateAttributes(NSRange, NSAttributedStringEnumeration, NSAttributedRangeCallback)

Applies the callback to all the attributes in the specified range.

(Inherited from NSAttributedString)
Equals(NSObject) (Inherited from NSObject)
Equals(Object) (Inherited from NSObject)
ExposedBindings() (Inherited from NSObject)
GetAppKitAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetAppKitAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetAttribute(String, nint, NSRange) (Inherited from NSAttributedString)
GetAttribute(String, nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetBindingInfo(NSString) (Inherited from NSObject)
GetBindingOptionDescriptions(NSString) (Inherited from NSObject)
GetBindingValueClass(NSString) (Inherited from NSObject)
GetBoundingRect(CGSize, NSStringDrawingOptions, NSStringDrawingContext) (Inherited from NSAttributedString)
GetCoreTextAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetCoreTextAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetData(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetData(NSRange, NSDictionary, NSError) (Inherited from NSAttributedString)
GetDataFromRange(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetDataFromRange(NSRange, NSDictionary, NSError)

d|To be added.

(Inherited from NSAttributedString)
GetDictionaryOfValuesFromKeys(NSString[])

Retrieves the values of the specified keys.

(Inherited from NSObject)
GetDocFormat(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetDocFormat(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetFileWrapper(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetFileWrapper(NSRange, NSDictionary, NSError) (Inherited from NSAttributedString)
GetFileWrapperFromRange(NSRange, NSAttributedStringDocumentAttributes, NSError) (Inherited from NSAttributedString)
GetFileWrapperFromRange(NSRange, NSDictionary, NSError) (Inherited from NSAttributedString)
GetFontAttributes(NSRange) (Inherited from NSAttributedString)
GetHashCode()

Generates a hash code for the current instance.

(Inherited from NSObject)
GetItemNumber(NSTextList, nuint) (Inherited from NSAttributedString)
GetItemProviderVisibilityForTypeIdentifier(String) (Inherited from NSAttributedString)
GetLineBreak(nuint, NSRange) (Inherited from NSAttributedString)
GetLineBreakByHyphenating(nuint, NSRange) (Inherited from NSAttributedString)
GetMethodForSelector(Selector) (Inherited from NSObject)
GetNativeField(String)
Obsolete.
(Inherited from NSObject)
GetNativeHash() (Inherited from NSObject)
GetNextWord(nuint, Boolean) (Inherited from NSAttributedString)
GetPasteboardPropertyListForType(String) (Inherited from NSAttributedString)
GetRange(NSTextBlock, nuint) (Inherited from NSAttributedString)
GetRange(NSTextList, nuint) (Inherited from NSAttributedString)
GetRange(NSTextTable, nuint) (Inherited from NSAttributedString)
GetRtf(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetRtf(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetRtfd(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetRtfd(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetRtfdFileWrapper(NSRange, NSAttributedStringDocumentAttributes) (Inherited from NSAttributedString)
GetRtfdFileWrapper(NSRange, NSDictionary) (Inherited from NSAttributedString)
GetRulerAttributes(NSRange) (Inherited from NSAttributedString)
GetUIKitAttributes(nint, NSRange) (Inherited from NSAttributedString)
GetUIKitAttributes(nint, NSRange, NSRange) (Inherited from NSAttributedString)
GetUrl(nuint, NSRange) (Inherited from NSAttributedString)
GetWritableTypesForPasteboard(NSPasteboard) (Inherited from NSAttributedString)
GetWritingOptionsForType(String, NSPasteboard) (Inherited from NSAttributedString)
Init() (Inherited from NSObject)
InitializeHandle(IntPtr) (Inherited from NSObject)
InitializeHandle(IntPtr, String) (Inherited from NSObject)
InitWithPasteboardPropertyList(NSObject, String)
Obsolete.
(Inherited from NSAttributedString)
Insert(NSAttributedString, nint)

Inserts an attributed string into the current string.

Invoke(Action, Double) (Inherited from NSObject)
Invoke(Action, TimeSpan) (Inherited from NSObject)
InvokeOnMainThread(Action) (Inherited from NSObject)
InvokeOnMainThread(Selector, NSObject)

Invokes synchrously the specified code on the main UI thread.

(Inherited from NSObject)
IsEqual(NSAttributedString)

Whether this is equal to the other string.

(Inherited from NSAttributedString)
IsEqual(NSObject) (Inherited from NSObject)
IsKindOfClass(Class) (Inherited from NSObject)
IsMemberOfClass(Class) (Inherited from NSObject)
LoadData(String, Action<NSData,NSError>)

Implement this method to customize the loading of data by an NSItemProvider.

(Inherited from NSAttributedString)
LoadDataAsync(String) (Inherited from NSAttributedString)
LoadDataAsync(String, NSProgress) (Inherited from NSAttributedString)
LowLevelGetAttributes(nint, NSRange)

Low-level version that provides an NSDictionary for the attributes in the specified range.

(Inherited from NSAttributedString)
LowLevelSetAttributes(IntPtr, NSRange)

Low-level version of SetAttributes for high throughput attribute setting.

MarkDirty()

Promotes a regular peer object (IsDirectBinding is true) into a toggleref object.

(Inherited from NSObject)
MutableCopy()

Creates a mutable copy of the specified NSObject.

(Inherited from NSObject)
MutableCopy(NSZone)

Performs a copy of the underlying Objective-C object.

(Inherited from NSAttributedString)
ObjectDidEndEditing(NSObject) (Inherited from NSObject)
ObserveValue(NSString, NSObject, NSDictionary, IntPtr)

Indicates that the value at the specified keyPath relative to this object has changed.

(Inherited from NSObject)
PerformSelector(Selector) (Inherited from NSObject)
PerformSelector(Selector, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSObject, Double)

Invokes the selector on the current instance and if the obj is not null, it passes this as its single parameter.

(Inherited from NSObject)
PerformSelector(Selector, NSObject, Double, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSObject, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean, NSString[]) (Inherited from NSObject)
PrepareForInterfaceBuilder() (Inherited from NSObject)
ReadFromData(NSData, NSAttributedStringDocumentAttributes, NSDictionary, NSError)
ReadFromData(NSData, NSDictionary, NSDictionary, NSError)
ReadFromFile(NSUrl, NSAttributedStringDocumentAttributes, NSDictionary, NSError)

Developers should not use this deprecated method. Developers should use 'ReadFromUrl' instead.

ReadFromFile(NSUrl, NSDictionary, NSDictionary, NSError)
ReadFromUrl(NSUrl, NSAttributedStringDocumentAttributes, NSDictionary<NSString,NSObject>, NSError)
ReadFromUrl(NSUrl, NSDictionary<NSString,NSObject>, NSDictionary<NSString,NSObject>, NSError)
RemoveAttribute(String, NSRange)

Removes the specified attribute from the range of characters

RemoveObserver(NSObject, NSString)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
RemoveObserver(NSObject, NSString, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, String)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
RemoveObserver(NSObject, String, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
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.

RespondsToSelector(Selector)

Whether this object recognizes the specified selector.

(Inherited from NSObject)
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.

SetAttributes(UIStringAttributes, NSRange)
SetNativeField(String, NSObject)
Obsolete.
(Inherited from NSObject)
SetNilValueForKey(NSString)

Sets the value of the specified key to null.

(Inherited from NSObject)
SetString(NSAttributedString)

Sets the contents of this NSMutableAttributedString to the value specified.

SetValueForKey(NSObject, NSString)

Sets the value of the property specified by the key to the specified value.

(Inherited from NSObject)
SetValueForKeyPath(IntPtr, NSString)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

(Inherited from NSObject)
SetValueForKeyPath(NSObject, NSString)

Sets the value of a property that can be reached using a keypath.

(Inherited from NSObject)
SetValueForUndefinedKey(NSObject, NSString)

Indicates an attempt to write a value to an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
SetValuesForKeysWithDictionary(NSDictionary)

Sets the values of this NSObject to those in the specified dictionary.

(Inherited from NSObject)
Substring(nint, nint) (Inherited from NSAttributedString)
ToString()

Returns a string representation of the value of the current instance.

(Inherited from NSObject)
Unbind(NSString) (Inherited from NSObject)
Unbind(String)
Obsolete.
(Inherited from NSObject)
ValueForKey(NSString)

Returns the value of the property associated with the specified key.

(Inherited from NSObject)
ValueForKeyPath(NSString)

Returns the value of a property that can be reached using a keypath.

(Inherited from NSObject)
ValueForUndefinedKey(NSString)

Indicates an attempt to read a value of an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
WillChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates that the values of the specified indices in the specified key are about to change.

(Inherited from NSObject)
WillChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
WillChangeValue(String)

Indicates that the value of the specified key is about to change.

(Inherited from NSObject)

Extension Methods

BoundingRectWithSize(NSAttributedString, CGSize, NSStringDrawingOptions, NSStringDrawingContext)
DrawWithRect(NSAttributedString, CGRect, NSStringDrawingOptions, NSStringDrawingContext)
ApplyFontTraits(NSMutableAttributedString, NSFontTraitMask, NSRange)
FixAttachmentAttributeInRange(NSMutableAttributedString, NSRange)
FixFontAttributeInRange(NSMutableAttributedString, NSRange)
FixParagraphStyleAttributeInRange(NSMutableAttributedString, NSRange)
ReadFromData(NSMutableAttributedString, NSData, NSAttributedStringDocumentAttributes, NSDictionary)
ReadFromData(NSMutableAttributedString, NSData, NSAttributedStringDocumentAttributes, NSDictionary, NSError)
ReadFromData(NSMutableAttributedString, NSData, NSDictionary, NSDictionary)
ReadFromData(NSMutableAttributedString, NSData, NSDictionary, NSDictionary, NSError)
ReadFromURL(NSMutableAttributedString, NSUrl, NSAttributedStringDocumentAttributes, NSDictionary)
ReadFromURL(NSMutableAttributedString, NSUrl, NSAttributedStringDocumentAttributes, NSDictionary, NSError)
ReadFromURL(NSMutableAttributedString, NSUrl, NSDictionary, NSDictionary)
ReadFromURL(NSMutableAttributedString, NSUrl, NSDictionary, NSDictionary, NSError)
SetAlignment(NSMutableAttributedString, NSTextAlignment, NSRange)
SetBaseWritingDirection(NSMutableAttributedString, NSWritingDirection, NSRange)
SubscriptRange(NSMutableAttributedString, NSRange)
SuperscriptRange(NSMutableAttributedString, NSRange)
UnscriptRange(NSMutableAttributedString, NSRange)
UpdateAttachmentsFromPath(NSMutableAttributedString, String)
ObjectDidBeginEditing(NSObject, INSEditor)
ObjectDidEndEditing(NSObject, INSEditor)
GetValidModes(NSObject, NSFontPanel)
ValidateToolbarItem(NSObject, NSToolbarItem)
GetPasteboardPropertyListForType(INSPasteboardWriting, String)
GetWritableTypesForPasteboard(INSPasteboardWriting, NSPasteboard)
GetWritingOptionsForType(INSPasteboardWriting, String, NSPasteboard)
DrawAtPoint(NSAttributedString, CGPoint)
DrawInRect(NSAttributedString, CGRect)
GetSize(NSAttributedString)
GetDebugDescription(INSObjectProtocol)
AcceptsPreviewPanelControl(NSObject, QLPreviewPanel)
BeginPreviewPanelControl(NSObject, QLPreviewPanel)
EndPreviewPanelControl(NSObject, QLPreviewPanel)
ContainsAttachments(NSAttributedString, NSRange)

Returns true if the current NSAttributedString contains attachments in the specified range.

FixAttributesInRange(NSMutableAttributedString, NSRange)

Cleans up inconsistencies that can accumulate over many edits.

GetAccessibilityCustomRotors(NSObject)

Gets the array of UIAccessibilityCustomRotor objects appropriate for this object.

SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor[])

Sets the array of UIAccessibilityCustomRotor objects appropriate for this object.

Applies to

See also