0

I have 1 UITableView with 2 sections. I did 2 headers, the first one is a picture with a blurred background of the same picture and the second is a `UISegmentedControl'.

I need the UISegmentedControl to always be visible so I fulfilled the second section of my UITableView.

Currently I am with:

this

Now what I want is the blurred image to go into half of my second header, the one with the UISegmentedControl, like this:

what I want

And to make it harder, I need this "half of background image" disappear when I scroll down on my UITableView. Is there anyway to manage to do it?

I'm working on Swift !

Bryan ORTIZ
  • 306
  • 3
  • 17

1 Answers1

1

It can be done updating constraints. But for this you don't need 2 headers. One header will do the thing where you should keep both the blurred image portion and the UISegmentedControl just like the first screenshot you provided. Make sure you set a vertical spacing constraint between these two items and take a IBOutlet of that constraint.

Now, do the following:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    constVerticalSpace.constant = -scrollView.contentOffset.y
   //Please keep a restriction of this constant otherwise the segment will go off screen.
}
Poles
  • 3,585
  • 9
  • 43
  • 91
  • The thing is I need the first header to disappear while scrolling down. But the second header should stay and get his background turning white depending while scrolling. – Bryan ORTIZ Sep 05 '16 at 12:07
  • No problem.... add it with the existing code I mentioned earlier. Change the first header alpha from 1 to 0.9,0.8...0.0 depends upon scrollview content offset. Now when its reaches to zero do the following. `if (imageview.aplha==0) imageview.hidden = YES`. – Poles Sep 05 '16 at 12:21
  • I'd like to try your solution, do you mind detailing it a bit ? I do have some descent skills on Swift but my english is much more limited, I'm not sure I do understand everything you wrote. Thanks ! – Bryan ORTIZ Sep 05 '16 at 13:42