<!--
{
  "availability" : [
    "macOS: 10.9.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSStackView/setCustomSpacing(_:after:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSStackView(im)setCustomSpacing:afterView:"
  },
  "title" : "setCustomSpacing(_:after:)"
}
-->

# setCustomSpacing(_:after:)

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

```
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 [`useDefaultSpacing`](/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

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`](/documentation/AppKit/NSView/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`](/documentation/AppKit/NSStackView/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

[`spacing`](/documentation/AppKit/NSStackView/spacing)

The minimum spacing, in points, between adjacent views in the stack view.



---

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)