<!--
{
  "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/contentScrollView(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)contentScrollViewForEdge:"
  },
  "title" : "contentScrollView(for:)"
}
-->

# contentScrollView(for:)

Returns the scroll view the view controller observes for the specified edge.

```
func contentScrollView(for edge: NSDirectionalRectEdge) -> UIScrollView?
```

## Parameters

`edge`

The edge the scroll view observes for alignment, [`top`](/documentation/UIKit/NSDirectionalRectEdge/top) or [`bottom`](/documentation/UIKit/NSDirectionalRectEdge/bottom). Passing any other value raises an exception.

## Return Value

The scroll view the view controller observes for the edge.

## 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. If you want to disable this behavior for one or more edges, override this method and return `nil` for the appropriate edge. If you don’t set a scroll view with [`setContentScrollView(_:for:)`](/documentation/UIKit/UIViewController/setContentScrollView(_:for:)) or [`setContentScrollView(_:)`](/documentation/UIKit/UIViewController/setContentScrollView(_:)), the default implementation of this method returns `nil`.

The following example disables the scroll edge view for the top edge only. This example disables the appearance changes of the navigation bar at the top edge, but not the toolbar at the bottom edge.

```swift
override func contentScrollView(for edge: NSDirectionalRectEdge) -> UIScrollView? {
    if edge == .top {
        return nil
    } else {
        return super.contentScrollView(for: edge)
    }
}
```

---

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)