---
title: "CFAttributedStringSetAttribute(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfattributedstringsetattribute(_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.corefoundation/documentation/CoreFoundation/CFAttributedStringRemoveAttribute(_:_:_:).

## See Also

### Modifying a CFMutableAttributedString

- [CFAttributedStringBeginEditing(_:)](corefoundation/cfattributedstringbeginediting(_:).md)
- [CFAttributedStringEndEditing(_:)](corefoundation/cfattributedstringendediting(_:).md)
- [CFAttributedStringGetMutableString(_:)](corefoundation/cfattributedstringgetmutablestring(_:).md)
- [CFAttributedStringRemoveAttribute(_:_:_:)](corefoundation/cfattributedstringremoveattribute(_:_:_:).md)
- [CFAttributedStringReplaceString(_:_:_:)](corefoundation/cfattributedstringreplacestring(_:_:_:).md)
- [CFAttributedStringReplaceAttributedString(_:_:_:)](corefoundation/cfattributedstringreplaceattributedstring(_:_:_:).md)
- [CFAttributedStringSetAttributes(_:_:_:_:)](corefoundation/cfattributedstringsetattributes(_:_:_:_:).md)
