Structure
AttributeContainer
iOS 15.0+
iPadOS 15.0+
Mac Catalyst 15.0+
macOS 12.0+
tvOS 15.0+
watchOS 8.0+
A container for attribute keys and values.
@dynamicMemberLookup struct AttributeContainer
Overview
AttributeContainer provides a way to store attributes and their values outside of an attributed string. You use this type to initialize an instance of AttributedString with preset attributes, and to set, merge, or replace attributes in existing attributed strings.
Topics
Structures
struct BuilderA type that iteratively builds attribute containers by setting attribute values.
Initializers
init()Creates an empty attribute container.
Instance Methods
func filter(inheritedByAddedText: Bool) -> AttributeContainerReturns a copy of the attribute container with only attributes that specify the provided inheritance behavior.func filter(runBoundaries: AttributedString.AttributeRunBoundaries?) -> AttributeContainerReturns a copy of the attribute container with only attributes that have the provided run boundaries.func merge(AttributeContainer, mergePolicy: AttributedString.AttributeMergePolicy)Merges the container’s attributes with those in another attribute container.func merging(AttributeContainer, mergePolicy: AttributedString.AttributeMergePolicy) -> AttributeContainerReturns an attribute container by merging the container’s attributes with those in another attribute container.
Subscripts
subscript<T>(T.Type) -> T.Value?Returns the attribute that corresponds to a specified key.subscript(dynamicMember:)Returns the attribute that corresponds to a specified key path.
Type Subscripts
static subscript<K>(dynamicMember _: KeyPath<AttributeDynamicLookup, K>) -> AttributeContainer.Builder<K>Returns a modified attribute container as part of building a chain of attributes, for use as a static method.
Default Implementations
Relationships
Conforms To
Swift.CopyableSwift.CustomStringConvertibleSwift.EquatableSwift.EscapableSwift.HashableSwift.SendableSwift.SendableMetatype