<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/setContentScrollView(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)setContentScrollView:forEdge:"
  },
  "title" : "setContentScrollView(_:for:)"
}
-->

# setContentScrollView(_:for:)

Sets the scroll view that bars observe for the specified edge.

```
func setContentScrollView(_ scrollView: UIScrollView?, for edge: NSDirectionalRectEdge)
```

## Parameters

`scrollView`

The scroll view to observe. If `nil`, the view controller determines a scroll view automatically.

`edge`

The edge to observe for scroll view content alignment. Pass [`top`](/documentation/UIKit/NSDirectionalRectEdge/top) or [`bottom`](/documentation/UIKit/NSDirectionalRectEdge/bottom) to set the scroll view for a specific edge, or pass [`all`](/documentation/UIKit/NSDirectionalRectEdge/all) to set the scroll view for all edges.

## Discussion

Toolbars, navigation bars, and tab bars adjust their appearance when the edge of a scroll view’s content aligns with the edge of the bar. The view controller identifies a scroll view to observe by analyzing the view hierarchy to select a scroll view. If the view hierarchy is complex, the view controller might not select the appropriate scroll view to observe. Use this method to indicate a specific scroll view for the view controller to observe.

To disable the scroll edge appearance for one or more edges, override [`contentScrollView(for:)`](/documentation/UIKit/UIViewController/contentScrollView(for:)).

---

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)