Scaling entire iPad app to fit status bar - ios

I've been searching SO and Google for a while now with no luck.
What I need to do, is in certain conditions, display a status bar at the top of my application.
When this bar shows, I need to shrink all the other content down so everything still fits on the screen.
I know I can use CGAffineTransformScale, however, I am not having any luck doing it globally for the entire app.
I'm sure I'm missing something obvious. Guess my lack of experience is showing.
Thanks
EDIT: The 'status' bar I'm referring to is NOT the standard iOS status bar. It is a custom status bar that appears only in certain conditions and sits at the top of the app.

I would check your autolayout settings on the first view you added to the controller - if you have them setup correctly then it should resize automatically.

If you use a UIViewController or any concrete subclass of that, its view should automatically adapt to whether or not the status bar is currently visible.
Now in case you use autoresizing masks, your UI should be fine. Same should apply if you use a UIScrollView.

Alternatively: In Interface Builder, select your view controller and on the attributes inspector turn off Layout: Wants Full Screen. Then, your layout will automatically adjust its size to make room for the navigation bar.

Related

iOS 11 - Adding Background image to Navigation bar

I have a view controller with Large Titles and I want to add a background image to it so it takes up the whole navigation bar.
Does anyone know the best way to do this. I've search all over the internet but yet to find any good examples.
Thank you
Goal is to look like this view from starbucks app.
I have checked the image. I think the best way is to add an image view at top. Then on that image view place two buttons with appropriate constraints. Then underneath that image view, add the tableview. Then in the table view cell, at first index you can add the textview, if it is a large text and underneath cells will cover all the things your require with labels in the left and the > image in the right which will lead to a different screen.
I ran into a similar problem just like this and I didn't find any solution over the internet neither. But I do have a simple work around that might be helpful.
What I did is setting the image as navigation bar's background and also add the image to the view in the VC. Make sure the navigation bar has no shadow and its translucent property is set to NO.

Creating custom implementation of navigation bar

I wish to create a view similar in behavior to the UINavigationBar.
I cannot simply customize the bar as I want the space to be taller and I want to have several other subviews on it other than just UIBarButtonItems. So, I want to be able to create a similar implementation including the floating/translucency effect.
I good example of this is the address bar in Safari in iOS 7. The UITextField on the bar is something that cannot be added on the default UINavigationBar. Nevertheless, the Safari bar still has the transparency.
I do not want it to shrink like it does in Safari when scrolling down, I simply want it to remain just like a UINavigationBar would. I was thinking about adding a subview to the root UIScrollView, but this would scroll along with everything. I want this to remain at the top, but I want other elements to be able to scroll.
How would I go about implementing this?
If you are confident that you can't to this with the default UINavigationBar, you could shrink (from the top) the UIScrollView with whatever the size the custom UINavigationBar is and then add the navbar as a subview to the root view at (0,0) coordinates. It will be independent from the scroll view.
On the other hand, if you need this to be persistent through the application and use it in all of the screens, it will be wise to make some changes starting for the AppDelegate, but that's for another question.
For the iOS 7 transparent-style part, look here: FXBlurView. Best of luck!

UISplitView with UITabbar

I have a strange one that I can not seem to fix. I am currently working on updating my app to iOS7. This all worked in iOS6. It is an universal app and thus uses same xib files. However the iPad uses UISplitViews on some. Like I said, this all worked in iOS6 oh this all works on the iPhone too.
The problem is a grey bar at the bottom. I changed the tab bar to be opaque to move views up properly as i had some UI clipped to bottom of views and that went underneath the tab bar, sidetracked there. But if i set it back to translucent bar, it goes underneath but stretched properly. if i dont, it adds a bar. Other tabs work fine when NOT using splitview.
The UISplitviewController is added programmatically.
See attached image for better description.
This I have tried:
Added autoresize on splitview
Checked xib for subviews in the splitviews to have auto resize
Tried to force splitview to be screen bounds
Removed clips to bounds on all views
Removed autoresize subviews
Any ideas would be welcomed.
Thank you all.
UPDATE:
setting the background colour the uisplitview, it does colour the bar black. So the uisplitview is definitely stretching to it.
I subclassed UISplitViewController and added the line below to viewDidLoad and that fixed the grey line.
self.extendedLayoutIncludesOpaqueBars = YES;
I believe I have found an alternative solution for you. I have had the exact same problem, mostly because we are both doing something against Apple's Guidelines which is having a SplitViewController nested within a Tabbar controller (SplitView should be the root view). This was okay in iOS 5/6, but now in iOS 7 there are far too many side effects to achieve this.
The reason you see your view stretch completely when you set the bar to be translucent is because the bar is NOT taken into account when drawing the view. When you set translucent to false, it is then taken into account of the view and you will see that grey bar there because that's your view pretending there's a tabbar at the bottom of the screen.
And as always, a SplitViewcontroller's height cannot be changed, as it is determined by the visible window height.
I tried everything you did and then some. The real solution came from using a third-party Split View Controller.
I recommend switching over to https://github.com/mattgemmell/MGSplitViewController . This split view controller is actually one large View with container views living inside of it. Because of this, you avoid all the side effects of putting an actual split view controller within a tab bar.
If that doesn't float your boat, you could create your own solution which follows the same idea of having one UIViewController with two container views contained in it, though the people behind MGSplitViewController did a good job of that already.
This was the only way I was able to solve this issue, let me know if you find an alternative.
Instead of creating a subclass for UISplitViewController, I just added this code on my master's viewDidLoad:
self.splitViewController?.extendedLayoutIncludesOpaqueBars = true
For the controller that is the detail view of UISplitViewController you just do this:
-(UITabBarController*)tabBarController{
return nil;
}

Blur top bar to UIView

I made a "single view" app with a UIView interface in a .xib file. I added a navigation bar at the top with some buttons on it and all worked fine in iOS 6.
With Xcode 5 my navigation bar is too short and buttons overlapped status bar. I tried to add a "top bar" in the "Simulated Metrics" panel but once I run the app the bar does not appear (even if it appears in the .xib file during editing).
Same problem when I tried a tool bar because I need a 64 pixel (instead 44) high blur bar.
Does a simple solution to this problem exist? Thanks!
Simulated metrics, while editing a storyboard and/or xib are, are there for you to use when stubbing out your design. They will not show up at run time. Think of them as fictional representations or a prototype of what you would like to see in your design without actually having to implement it yet.
IE: You're not sure if you want a UINavigationBar in your design. You can layout your design with the UINavigationBar turned on in the simulated metrics and it'll show you what it looks like, but only in the editor not actual run time, and from there you can make your decision on whether or not to keep it or rearrange your other controls. Something like this is very handy if you create your UINavigationBar programmatically (like I do). If I simulate the UINavigationBar (even though I'll create it programmatically) then I can get a much better idea of where to layout all my other controls that I DO setup in IB.
All that being said, if you layout all your xib's and SB's in the interface builder then the simulated metrics really is worthless to you for the most part because you can obviously just drag and drop the control onto your xib.
Hope this helps!

Simple Horizontal Button Bar for iOS

I have a requirement for a very simple Button Bar.
It should take up the width of the screen.
It should allow at least 3
buttons.
The buttons should be of equal width and together take up
the whole width of the bar.
Each button should be tappable, but not
have a selected state.
The bar will be overlaid on a MapView and positioned directly above a TabBar.
Tapping a button will launch a Modal ViewController.
I thought about using a UITabBar and not allowing its tabs to become selected, but the HIG is pretty clear that this is not correct usage and UIToolBar doesn't allow the button widths to be set.
This seems like a very simple requirement but I can't see an obvious solution. Is there something I'm missing? Can anyone suggest a solution?
What's wrong with just creating a simple view that draws an appropriate gradient, and then adding three buttons of the appropriate size?
If you're feeling ambitious, or if this is something that you're likely to use more than once, you could even have the view create the three buttons. Call it ThreeButtonBar or something. Give it a constant height and adjust the width to match that of its superview so that you can use it in portrait or landscape orientation.

Resources