Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Support for non-translucent navigation bars? #7

Closed
DimaVartanian opened this issue Jul 2, 2014 · 12 comments · Fixed by #97
Closed

Support for non-translucent navigation bars? #7

DimaVartanian opened this issue Jul 2, 2014 · 12 comments · Fixed by #97

Comments

@DimaVartanian
Copy link

I made a simple project with a UIViewController with a UITableView inside it. By default, it all works fine. Changing the translucent property of the navigation bar to NO however causes some issues. It seems the reason is this component depends on a translucent bar as it only adjusts the content inset of the scroll view (and a scrollview with a non translucent bar doesn't use this functionality since there is no hidden portion). When the navigation bar hides, it leaves a blank space in its place since the underlying view does not actually extend underneath it.

Sample project here: http://cl.ly/2D2F090o2I3d

Wondering if there is a straightforward way to solve this.

The way I have solved it in my app for the short term is as follows:

  1. manually extend the frame of the scroll view underneath the nav bar (so decreasing origin.y and increasing size.height both by the height of the navigation bar)
  2. overriding topLayoutGuide to return a custom object with length being the height of the navigation bar so TLYShyNavBar can use that value as if the navigation bar is transparent without knowing or caring that it isn't.

This solution is working for me at the moment and behaves smoothly but has a few issues. First off, I don't see a way of easily extending this functionality into the component. The second is that overriding the layout guide seems to actually be unsupported behavior and although it is working for me, can cause some issues with autolayout, as shown here.

What do you think?

@Mazyod
Copy link
Contributor

Mazyod commented Jul 3, 2014

Well, first, yes. You're absolutely right about the cause of the issue. If you noticed, facebook changes the bounds and the contentInsets, and it feels right to see the scroll indicators to move up along side the navbar. I wanted to make that change, but didn't find a good excuse to throw the current implementation... not until now.

Your solution is the way to go! We just need to avoid overriding the layout guides, and make the bound changes within the component. I can take a look at it tonight, or if you care to submit a PR, that would be great as well! If you don't have the time, I think this solution is actually non trivial, since it will require a new "coupling" that doesn't exist now, which is between the TLYShyViewController (the contraction/expansion amount) and the UIScrollView (the bounds).

@basilmariano
Copy link

Im actually experiencing this too, And I don't override,

@Mazyod : Hopefully you can support this soon,

@iSevenDays
Copy link
Contributor

On your view try setting
self.extendedLayoutIncludesOpaqueBars = YES;

@red010182
Copy link

@iSevenDays thanks, it works perfect

@iSevenDays
Copy link
Contributor

@red010182 glad to help you :)

@Mazyod
Copy link
Contributor

Mazyod commented Oct 27, 2014

Anyone thinks the component should check if the navbar is opaque, and do the extendedLayoutIncludesOpaqueBars automatically?

@red010182
Copy link

It would be really fantastic to do so.

Mazyad Alabduljaleel notifications@github.com 於 2014年10月28日星期二寫道:

Anyone thinks the component should check if the navbar is opaque, and do
the extendedLayoutIncludesOpaqueBars automatically?


Reply to this email directly or view it on GitHub
#7 (comment).

@Mazyod
Copy link
Contributor

Mazyod commented Oct 29, 2014

After experimenting with it, it seems like it is not a silver bullet 😢

I tried to implement the bounds change approach, and it worked well for opaque navbars, but that broke the translucent navbars... This bug in iOS 7 doesn't help at all:
http://stackoverflow.com/questions/19595479/calling-toplayoutguide-breaks-scrolling-altogether

@mgrider
Copy link

mgrider commented Mar 31, 2015

I also have a need for non-translucent nav bars. Odd thing is, I am using TLYShyNavBar in two views in my app, and one of them appears translucent, and the other does not. I assumed I was just missing something until reading in this thread that an opaque nav bar is not supported.

@joshbernfeld
Copy link

@iSevenDays thanks that did it for me.

@astine-daniel
Copy link

I'm using a translucent nav bar, but It's showing a black space when the nav bar is hidden. I'm using a tableview with auto layout.

@Mazyod
Copy link
Contributor

Mazyod commented Nov 7, 2015

@astine-daniel Thanks for reporting this. Are you sure it's translucent? There is already a demo shipping with the component that confirms it should work. If you're sure it's translucent, you may want to check #64, this issue is about non-translucent bars.

@Mazyod Mazyod mentioned this issue Nov 15, 2015
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants