views:

571

answers:

2

I have a UIScrollView which contains a view (lets call this "main view") which scrolls along the X and Y axis.

I am trying to transparently overlay a heading over this view which is fixed at the top of the screen (not view) but scrolls along the X axis as the main view does. When the main view scrolls along the Y axis the heading remains at the top of the screen.

What would be the best approach to achieve this?

+1  A: 

I would not put the view in the scrollview at all. Use the scroll view delegate to catch when the scroll view is panning and move your subview horizontal manually.

Squeegy
+2  A: 

Create a container view for both your indicator view and the scrollview. Make it the size of the screen.

Add both the UIScrollView and your HeadingView to this as Subviews. The Heading will then stay still as the scrollview pans. You can update the heading based on messages to a UIScrollViewDelegate you add to the Scrollview. scrollViewDidScroll: is the most obvious but you can get other notifications.

Roger Nolan