---
title: "setAlignment(_:range:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutableattributedstring/setalignment(_:range:)"
---

# setAlignment(_:range:)

Sets the alignment characteristic of the paragraph style attribute for the specified range of text.

## Declaration

```swift
func setAlignment(_ alignment: NSTextAlignment, range: NSRange)
```

## Parameters

- `alignment`: The alignment to use.
- `range`: The range of characters.

## Discussion

Discussion When attribute fixing takes place, this change will affect only paragraphs whose first character was included in range. Raises an rangeException if any part of range lies beyond the end of the receiver’s characters.

## See Also

### Related Documentation

- [fixParagraphStyleAttribute(in:)](foundation/nsmutableattributedstring/fixparagraphstyleattribute(in:).md)

### Changing Attributes

- [setAttributes(_:range:)](foundation/nsmutableattributedstring/setattributes(_:range:).md)
- [addAttribute(_:value:range:)](foundation/nsmutableattributedstring/addattribute(_:value:range:).md)
- [addAttributes(_:range:)](foundation/nsmutableattributedstring/addattributes(_:range:).md)
- [removeAttribute(_:range:)](foundation/nsmutableattributedstring/removeattribute(_:range:).md)
- [applyFontTraits(_:range:)](foundation/nsmutableattributedstring/applyfonttraits(_:range:).md)
- [setBaseWritingDirection(_:range:)](foundation/nsmutableattributedstring/setbasewritingdirection(_:range:).md)
- [subscriptRange(_:)](foundation/nsmutableattributedstring/subscriptrange(_:).md)
- [superscriptRange(_:)](foundation/nsmutableattributedstring/superscriptrange(_:).md)
- [unscriptRange(_:)](foundation/nsmutableattributedstring/unscriptrange(_:).md)
