0

On the profile screen of the Twitter iPhone app, when you scroll down, the UISegmentedControl sticks to the top of the screen. I'm wondering...how did they do that? I'm also wondering how they stretch the image when you pull, and how your name moves up into the nav bar, but I think those might belong as separate questions.

Andrew
  • 227,796
  • 193
  • 515
  • 708
  • My first guess is that they put it in a header row, assuming the entire thing is implemented as a table view. However, unless they literally made everything after the segmented control a single section, I can't see why it would stick all the way till the end of the user timeline past all the other sections. – BoltClock Jul 28 '15 at 04:19

1 Answers1

1

You can create a sticky header inside a UIScrollView by setting the y position of the header to equal the vertical content offset when handling the scrolling event through the UIScrollViewDelegate. Take a look at this answer.

For stretching the image, again inside the scrollView: didScroll: call you can apply the transformation you want based on content offset.

Obviously, there are many other ways to achieve these effects.

Community
  • 1
  • 1
Antonis
  • 114
  • 7