<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFAttributedStringSetAttribute(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFAttributedStringSetAttribute"
  },
  "title" : "CFAttributedStringSetAttribute(_:_:_:_:)"
}
-->

# CFAttributedStringSetAttribute(_:_:_:_:)

Sets the value of a single attribute over the specified range.

```
func CFAttributedStringSetAttribute(_ aStr: CFMutableAttributedString!, _ range: CFRange, _ attrName: CFString!, _ value: CFTypeRef!)
```

## Parameters

`aStr`

The mutable attributed string to modify.

`range`

The range of `aStr` over to which the new attributes apply. `range` must not exceed the bounds of `aStr`.

`attrName`

The name of the attribute whose value to set.

`value`

The value of the attribute `attrName` to apply over `range`. This value may not be `NULL`. If you want to remove an attribute, use [`CFAttributedStringRemoveAttribute(_:_:_:)`](/documentation/CoreFoundation/CFAttributedStringRemoveAttribute(_:_:_:)).

## Discussion

---

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)