On iOS devices the section headers in UITableView’s have a nice behavior where they stick or ‘float’ to the top of the screen as you scroll through a section. The section headers in my particular case are loaded from other XIB files.
Is it possible to change the section headers depending on whether or not they are currently floating? Specifically I’d like to add a small shadow to appear under the header only while it’s stuck to the top of the view.
Thanks!
I haven’t tested it yet, but I don’t see any reason why it wouldn’t be possible.
Just make sure you set the right
bounds(because your shadow needs to be on top of your view, not above it).You can use the following approach:
scrollView:didScroll:to get notified about scroll-events.[view addSubview:shadowView].) Something likeCGRectMake(0.f, yourDefaultHeaderHeight, 320.f, yourShadowHeight)should be theframeof yourshadowView.boundsofview, so it can show yourshadowView:CGRectMake(0.f, 0.f - yourShadowHeight, 320.f, yourDefaultHeaderHeight + 2 * yourShadowHeight).scrollView:didScroll:), remove the shadow-view.Your
headerViewsboundsshould be0.f - yourShadowHeightbecause if you use just0.f, it’ll blur (I don’t know why …).