Connect UIScrollView to Navigation Bar without the ScrollView being at index 0

So in an effort to make my app a little more aesthetically pleasing, I want to implement a blurred background beneath my UIScrollView. But to do this I have to put the background image at index 0 of the containing view, which breaks the link between the UIScrollView and the Navigation Controller.


I've read some older articles about changing the offset of the scrollview as a fix, but this was before iOS 11 brought the new large collapsing bar that I am trying to implement. Changing the offset will not cause the bar to start collapsing correctly. I'm doing all of this in the interface builder, but I'm definately not opposed to adding Swift code to get it to work.


The incorrect behavior is visible in the first image, with the blurred background at index 0 of the root view and the UIScrollView at index 1. The correct behavior is on the second link, where I had to remove the background and set the UIScrollView at index 0 to get the Navigation Bar to collapse with scrolling.


The links below

Incorrect behavior:

i.stack.imgur.com/MjkYx.gif


Correct behavior:

i.stack.imgur.com/dkprX.gif

Replies

Does anyone have any advice on this issue? I'm still having issues finding a workaround.

The way I fixed this was by putting the scroll view at index 0 in the storyboard and then programmatically moving whatever other view you want at index 0 to index 0.
view.sendSubviewToBack(<#T##view: UIView##UIView#>)
(This can be done in ViewDidLoad or wherever.)