<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVTextStyleRule",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVTextStyleRule"
  },
  "title" : "AVTextStyleRule"
}
-->

# AVTextStyleRule

An object that represents the text styling rules to apply to a media item’s textual content.

```
class AVTextStyleRule
```

## Overview

You use text style objects to format subtitles, closed captions, and other text-related content of the item. The system applies these rules to all or part of the text of the media item.

## Topics

### Creating and initializing style rules

[`+  textStyleRulesFromPropertyList:`](/documentation/AVFoundation/AVTextStyleRule/textStyleRules(fromPropertyList:))

Creates an array of text style rule objects from the specified property-list object.

[`+  textStyleRuleWithTextMarkupAttributes:`](/documentation/AVFoundation/AVTextStyleRule/textStyleRuleWithTextMarkupAttributes:)

Creates a new text style rule object using the style attributes in the specified dictionary.

[`+  textStyleRuleWithTextMarkupAttributes:textSelector:`](/documentation/AVFoundation/AVTextStyleRule/textStyleRuleWithTextMarkupAttributes:textSelector:)

Creates a new text style rule object using the specified style attributes and text range information.

[`-  initWithTextMarkupAttributes:`](/documentation/AVFoundation/AVTextStyleRule/init(textMarkupAttributes:))

Creates a text style rule object with the specified style attributes.

[`-  initWithTextMarkupAttributes:textSelector:`](/documentation/AVFoundation/AVTextStyleRule/init(textMarkupAttributes:textSelector:))

Creates a text style rule object with the specified style attributes and text range information.

### Accessing the style attributes

[`textMarkupAttributes`](/documentation/AVFoundation/AVTextStyleRule/textMarkupAttributes)

A dictionary of text style attributes to apply to the text.

[`textSelector`](/documentation/AVFoundation/AVTextStyleRule/textSelector)

A string that identifies the text the style attributes apply to.

### Exporting the style rules

[`+  propertyListForTextStyleRules:`](/documentation/AVFoundation/AVTextStyleRule/propertyList(for:))

Converts one or more text style rules into a serializable property list object.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)