subinspathilettu / SJSegmentedViewController

MIT License
334 stars 126 forks source link

Container View getting pushed down if UINavigationBar + Translucent? #38

Closed fabiosoft closed 7 years ago

fabiosoft commented 7 years ago

I have a UIViewController with a Container View. This Container View contains a UITableViewController.

The UIViewController is embedded in a UINavigationController. I configure the NavigationBar by changing the tint color, the bar tint color and the title text attributes, but when I try to change the translucency I have a problem

UINavigationBar.appearance().isTranslucent = false

When translucent = YES

+---------------------------------+
|                                 |
|     UINavigationBar             |
|                                 |
+---------------------------------+
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|    UITableViewController        |
|    in a Contained View          |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
+---------------------------------+

when translucent = NO

+---------------------------------+
|                                 |
|     UINavigationBar             |
|                                 |
+---------------------------------+
|                                 |
|blank space created on top of view
|                                 |
+---------------------------------+
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|     UITableViewController       |
|     in a Contained View         |
|                                 |
+---------------------------------+
andrewjlow commented 7 years ago

I have the same issue too.

With this setting UINavigationBar.appearance().isTranslucent = false I get the following:

image

With this setting UINavigationBar.appearance().isTranslucent = true I get this:

image
olivierpascal commented 7 years ago

+1

I think the problem is in SJUtil::getTopSpacing() that does not take in consideration isTranslucent.

pmarrufo commented 7 years ago

Here is what I did to solve my problem. For the navigation bar I added the following if statement if !(navigationController?.navigationBar.isOpaque)! { topSpacing += (navigationController?.navigationBar.bounds.height)! } For the tab bar I modified the following if statement if !tabBarController.tabBar.isHidden && !tabBarController.tabBar.isOpaque { bottomSpacing += tabBarController.tabBar.bounds.size.height }

pratikgajbhiye222 commented 3 years ago

still m facing same issue Help?

sudhakar-varma commented 2 years ago

@pratikgajbhiye222 if !(navigationController?.navigationBar.isTranslucent)! { topSpacing -= (navigationController?.navigationBar.bounds.height)! + 3 }else{ topSpacing += (navigationController?.navigationBar.bounds.height)! }