Setting the Navigation Bar to cover the Status bar in Modal Segues - ios

This could be a stupid question but i couldn't figure it out.
When i create a Push Segue it automatically should give me this if has a nav controller
while when i create a Modal Segue i need to set a navigationBar from the palette and looks like this
How can i make a custom navBar dragged from the palette to look like the first one?
I need this because i set the Status Bar text to white in order to be in contrast with the navigation bar color, but in this was the status bar is invisible, being white on the white background

You could add a property to the offset and height constraints. Then in the viewWillAppear method, set the constraints value to be -20 and 64 respectively
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear];
[self.myNavBarTopConstraint setConstant:-20];
[self.myNavBarHeightConstraint setConstant:64];
}

The problem is that you are creating your own title bar.. what you should do.. instead of presenting modally the destination view controller... present modally a navigationcontroller.. that has the destination view controller set as root view controller.
hope you can understand what tried to say =P!
GL HF
hope this helps

Related

ViewController in separate storyboard using RBStoryboardLink has extra 20px black status bar when hide navigation bar

I tried using RBStoryboardLink to separate storyboard in my project, and in one of the storyboard, I have an initial view controller which is embedded in navigation controller,and I use [[self navigationController] setNavigationBarHidden:YES animated:NO]; to hide navigation bar.
However it will introduce a 20px black area in status bar as below
I have tried options such as uncheck extend edges under top bars or uncheck adjust scroll view insets but nothing works so far.
anyone has any clue how to resolve this issue?
Thanks.
Ok, I managed to find a solution for my case.
The key is _needsTopLayoutGuide
I customised another called RBStoryboardNoNavLink and set _needsTopLayoutGuide to NO in that class, and if the storyboard link is a tab child view controller and do not want navigation bar (or do not embed in navigation controller even), can just rename that class to RBStoryboardNoNavLink and it works perfectly for my case.

Navigation Bar appears under a large status bar when using TabBarController

When I added a TabBarController, the navigation bar of TestController appears under a large status bar (see screenshot). Am I missing a setting somewhere? Thanks.
Here it is not clear what do you want to do with navigation bar.If you want to just hide navigation bar,then hide it when you add navigation bar to tab bar controller or you can hide it seperately in each view controller.
UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:vcPictureListing];
nav1.navigationBarHidden=TRUE;
or for doing it in each viewcontroller you can do it like
self.navigationController.navigationBar.hidden=TRUE;
This is just for hiding default one.If you want any navigation bar to be present then you can hide this default one and add imageview and button at top of viewcontroller and can have custom one
if you have added an image for naviagationbar then check you have not added shadow image for navigationbar. Check shadow image propery of navigationbar.

How to push entire view in iOS including navigation bar and toolbar

I have 3 views connected together via a navigation controller. The middle view (#2) has special styling in that the navigation bar and toolbar are completely white to blend in with the white background.
When swiping to/from view 2 the navigation and toolbar transition is animated (as is the default) to slowly fade in the buttons and styling of the view being pushed/popped i.e. the navigation bar and toolbar remain visible during the transition.
This ends up not looking to great because of the white navigation bar and toolbar of view 2.
What I would like to achieve instead is to have each view pushed/popped in entirety i.e. including its navigation bar and toolbar. In other words, instead of the navigation bar and toolbar to persist during the transition, I would like them to slide in/out with the view they are part of.
I have attached screenshots of the 2 variants.
Would it be best to scrap the navigation controller and set up each view with its own navigation bar and toolbar? Or can this be achieved easily for my current setup.
It would be great if someone could point me in the right direction.
This is from the Apple Remote app showing the effect I would like to create.
This is from the Apple Mail app showing the default transition effect.
Use custom transitions between view controllers will give you a better effect than animating UIView's, though you can add physics behaviors to UIView objects to make it more interesting.
Apple uses interactive custom transitions (just look that up) for its own apps. Here is a good article about that too:
http://www.doubleencore.com/2013/09/ios-7-custom-transitions/
Create your view with the desired screen with navigation bar & tollbar.
On the action bring the view 2 or remove with the animation your want using view animation.
[UIView animateWithDuration:0.2
animations:^{set your fram(0,0,320,480/568) or (320,0,320,480/568)}
completion:^(BOOL finished){
}];
You can add the view to keywindow.
Hope this will help you.
Why don't you simply use the hidesBottomBarWhenPushed property over the destination view controller?
// hide the bottom tabbar when we push this view controller
destinationViewController.hidesBottomBarWhenPushed = YES;

Transitioning between transparent navigation bar to translucent

In Apple's recently released Remote app I noticed the way in which the navigation bar behaves is unique and I haven't been able reproduce it. When popping the Now Playing view controller the navigation bar remains transparent for the Now Playing view controller and the navigation bar for the library view controller also stays translucent (Screenshot 1). I'm trying to figure out if they are using two navigation controllers or only one. Personally I feel they're using just one for two reasons (1) the interactive pop gesture is enabled; (2) when you press the 'Now Playing' button in the library view controller, just before the now playing screen has finished 'push view controller' animation the navigation bar becomes transparent (Screenshot 2). This is the behaviour I experience when pushing my view controller (which sets the navigation bar to transparent). So my question is: How does Apple present both navigation bars of the two view controllers as if they were individual (as with Screenshot 1), even the bar buttons, navigation title etc... are 100% in opacity when switching (usually when pushing/popping the buttons and titles of the previous view controller fade as the new controller is being pushed). I've tried playing around with the bar tint colour in viewDidAppear and viewWillAppear in both view controllers but cannot reproduce the same behaviour, and cannot prevent the bar buttons from fading.
Gosh I hope I've explained this well, I get confused just thinking about it!
Screenshot 1 (Popping):
Screenshot 2 (Pushing):
I just downloaded the application to make sure. Two different navigation bars are used. You can see this by using the interactive pop gesture. Notice how the navigation bar on the bottom view controller slides in and out. During normal push and pop transitions, the navigation items just fade in and out on the existing bar, while the bar is stationary. This is what happens up until the point where the now playing view controller is pushed.
If you look quickly, during the now playing view controller animation, you can see the bottom navigation bar disappear.
From my experience with UIKit behavior and what I see in the app, here is what I think happens:
album_vc = the bottom, list view controller
nowplaying_vc = the top view controller
On nowplaying_vc's viewWillAppear:
Set the navigation bar to hidden using [self.navigationController setNavigationBarHidden:YES animated:YES];. Since this is in animation block, this will make the navigation bar slide out during the push animation.
Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; Pretty sure about this, because notice there is no animation in the transition of the status bar styles. It just becomes white.
On nowplaying_vc's viewWillDisappear:
Set the navigation bar to shown using [self.navigationController setNavigationBarHidden:NO animated:YES];. Since this is in animation block, this will make the navigation bar slide in during the pop animation.
Set [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; Again, notice how during interactive pop gesture, the status bar just changes with no animation.
To achieve the transparent look of the navigation bar of nowplaying_vc, you can use an empty image ([UIImage alloc]) with setBackgroundImage:forBarPosition:barMetrics:.
Since the application does not rotate, we can't be sure if the navigation bar on nowplaying_vc is part of another navigation controller or just a navigation bar on the top with a position of UIBarPositionTopAttached. For all we know, there isn't even a navigation bar there but just a back chevron image view (back bar button is comprised of an image view and a button).
I think the status bar style is changed in viewWillAppear: and viewWillDisappear: due to the unnatural feel there is during interactive pop gesture. I would recommend using an animated transition, or even better, use the new view controller-based status bar style, which the system animates transitions by itself.
Update for modern API:
You should use the animateAlongsideTransition:completion: or animateAlongsideTransitionInView:animation:completion: API, rather than relying on the implicit animations of viewWillAppear: and viewWillDisappear:.
Instead of hiding and showing the navigation bar, you can update the alpha for the navigation bar. It will animate smoothly during the transition. For the view controller with transparent nav bar, instead of modifying the nav bar, create a navbar (or just the back button and title etc.) manually in the second controller's view. We will then hide the navbar when transitioning from first view controller to the second one.
On your first controller's viewWillDisappear and on your second view controller's viewWillAppear:, set the navigation bar alpha to zero using self.navigationController.navigationBar.alpha = 0;. Since this is in animation block, this will make the navigation bar disappear during the push animation.
Set the alpha back to one in first controller's viewWillAppear and second controller viewWillDisappear.

How do I add back button to UINavigationBar programmatically?

I have a UINavigationController and when I push one of my views, I have a UINavigationBar on top that I made an ivar for and connected it. Now what I need is that button that is like half square and half arrow on the left of the bar. How would I do this programmatically? All I need it to do is say back and do my back action when it is clicked. How would I do this?
Thanks!
If you're using a UINaviationController, then each view controller that you push onto it does not need it's own UINavigationBar object set up in the nib or in code. You get it and a back button 'for free' when you push a view controller onto a navigation controller's stack.
So remove the UINavigationBar from your pushed view controller. It could actually be blocking the navigation controller's navigation bar.
If you're using a nib to set up your view controller, you can add a 'simulated element' so that you have a fake navigation bar in the nib to help lay out your UI elements.
EDIT: in Xcode 4, they're now called 'Simulated Metrics'. Set the 'Top Bar' to simulate a navigation bar in your nib.

Resources