---
title: "setCustomSpacing(_:after:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsstackview/setcustomspacing(_:after:)"
---

# setCustomSpacing(_:after:)

Specifies the custom spacing, in points, between a specified view and the view that follows it in the stack view.

## Declaration

```swift
func setCustomSpacing(_ spacing: CGFloat, after view: NSView)
```

## Parameters

- `spacing`: The custom trailing space to use between the aView view and the one that follows it, in points. Default value is doc://com.apple.appkit/documentation/AppKit/NSStackView/useDefaultSpacing, which indicates that the view does not use custom spacing.
- `view`: The view whose trailing spacing you are setting. important: If you attempt to set custom spacing for a view that is not in the stack view, the system raises an exception.

## Discussion

Discussion For a horizontal stack view, this method sets custom spacing between a specified view and the view to its right when the user interface direction is left to right. (See the inherited userInterfaceLayoutDirection property for information on layout direction.) For a vertical stack view, this method sets custom spacing below a specified view. If you set custom spacing for a view, it overrides the stack view’s default spacing for that view, as set in the spacing property. A stack view retains custom spacing across layout updates. Custom spacing for a view is lost if you remove the view from the stack view or specify a new value.

## See Also

### Related Documentation

- [spacing](appkit/nsstackview/spacing.md)

### Configuring Views in a Stack View

- [customSpacing(after:)](appkit/nsstackview/customspacing(after:).md)
- [visibilityPriority(for:)](appkit/nsstackview/visibilitypriority(for:).md)
- [setVisibilityPriority(_:for:)](appkit/nsstackview/setvisibilitypriority(_:for:).md)
- [NSStackView.VisibilityPriority](appkit/nsstackview/visibilitypriority.md)
- [useDefaultSpacing](appkit/nsstackview/usedefaultspacing.md)
