How to add a bar on top of the iphone screen (below status bar)? - objective-c

Can someone advise me on how I can implement a "touch to return to call" type of UI as seen in the screenshot below?
My intention is to display the bar on top when my application receives a notification.
Any guide or resources on this will be greatly appreciated

There is several ways how you can place something below your status bar.
1. You can add UIView to UIWindow and position it to be under status bar. Set status bar style to black translucent, so the underneath view will be visible. Resize rootViewController appropriately, so it won't overlap your view.
2. Also, you can set wantsFullScreenLayout property of your rootViewController to true, so it'll cover the entire screen and manage view hierarchy inside it. You also need to set status bar style to black translucent.
Alternatively, you can add views above status bar, but I don't think that this is a good user experience. Here is how you can do that: Add UIView Above All Other Views, Including StatusBar

Related

iOS 7, status bar and navigation bar: hiding or sliding with side panels as Reeder does

I suppose this is an old one. I have a sliding panel (JASidePanel) with a menu and I want to hide or slide the status bar while showing the menu. So, I have two options:
Hide the status bar and keep the height of my navigation bar.
Or slide the status bar with the panel.
I see these two options are possible. The first one via swizzling of the sizeToFit of the UINavigationBar (link). The second one via a snapshot of the screen before animating the panel.
But I see Reeder, that takes the second option and brings it to another level: the panel is not really a screenshot, is the actual view of the panel so the status bar is slide but continues being updated, also the panel does!
So, I have a couple of questions: how is the Reeder solution possible? And the second one, is it secure to perform method swizzling? Could it be rejected by Apple?
Thank you.
Finally I implemented the first solution as shown in this link.

How animate the title / buttons in the UINavigationBar

I have in the UINavigationBar status information about the health of the app. It change the title text color, and one of the buttons there.
The changes work fine, but I wish to provide a smooth animation (because the status update on data changes) but don't know how. I'm not asking about moving to another views, but about how animate only the UINavigationBar titles & buttons.
I don't think you can animate those things without some extra work.
A navigation bar is a complex beast, and by default the UI objects that appear on the screen are private and maintained by the navigation bar or the current navigation item.
There should be a way to make it work however.
The current navigation item has a property titleView. normally it's nil and the navigation bar displays a title string itself. But if you plug a UILabel into the titleView property then you should be able to do animations on the animatable properties of the titleLabel.
Likewise with the bar button items.

How to make the status bar translucent in iOS 7?

In my app, I have some webviews. A transparent status bar doesn't look good for full screen webview. I want to make the status bar TRANSLUCENT, just like the game center.
I notice that the status bar would be drawn translucent if there is a navigation bar under it. But I want a translucent status bar BY ITSELF.
Is there any way to do this?
If you look at the Human Interface Guidelines section about the Status Bar it recommends (emphasis mine on the section most related to your question):
Prevent scrolling content from showing through the status bar. As
users scroll, you don’t want them to see a confusing mix of app
content and status bar items in the status bar area. To give users the
impression of spaciousness while still ensuring maximum readability,
make sure the status bar has a background that obscures the content
behind it. Here are a few ways to keep scrolling content from showing
through the status bar:
Use a navigation controller to display content. A navigation controller automatically displays a status bar background and it ensures that its content views don’t appear behind the status bar. (To learn more about navigation controllers, see “Navigation
Controllers”.)
Create a nondistracting custom image—such as a gradient—and display it behind the status bar. To ensure that the image stays behind the status bar, you could use a view controller to keep the image above a scrolling view or you could use a scrolling view to keep it pinned to the top.
Position content to avoid the status bar area (that is, the area defined by the app’s statusBarFrame property). If you do this, you should use the window’s background color to provide a solid color behind the status bar.
As the status bar is totally transparent and any content can go on top of it, I just create an empty UIToolbar that is 20px height which just looks like a perfect translucent background for the status bar.
This is not an ultimate solution, but it really helps and it is very easy to implement when you don't need a real tool bar.
Thanks to Apple that they do not provide an option to set the status bar from transparent to translucent.
In Xcode 6, create top, bottom, left, right constrains and set the
- constants to 0
- priorities to 749.
- Don't forget to UNCHECK the "Constrain to margins" check box.
How to create constrains?
At the bottom right of your storyboard window, there's four buttons. The second from your left has the constrains. Please google about constrains in Xcode 6 since it's a kinda new feature.
Hope this help,

Use custom Navigation Bar in iOS

I added a Navigation Bar to the .xib.
I did that because I want to customize a lot of things of it. I want my navigation controller to use that navigation bar in that screen.
I created the outlet named navBar and did:
[self.navigationController.navigationBar = navBar;
But it says that navigationBar is readonly. Is it possible to link my existing navigation controller with the navigation bar that I added to the screen?
It sounds to me that you may not actually want to use a UINavigationBar. As it states in the reference documentation:
The UINavigationBar class implements a control for navigating hierarchical content. It’s a bar, typically displayed at the top of the screen, containing buttons for navigating up and down a hierarchy. The primary properties are a left (back) button, a center title, and an optional right button. You can specify custom views for each of these.
So if you're planned customizations go beyond adding buttons, changing it's color / background, opacity, hiding etc.. you might be better off creating a UIView that mimics the look & feel of a navigation bar.
Here's an example of how to give your UIView that gradient look of a navigation bar.
It's far more flexible and actually quite easy to do BUT you've got alot of reading and testing ahead of you :).
Just in case if it's just buttons you're thinking of adding you might be better off using UIToolbar instead
You can't do that. Since the navigation controller's navigation bar has a lot of settings embedded, it's a readonly property and you shouldn't be able to change it.
What exactly are you trying to achieve that you need to do that via interface builder. I mean, with the newest APIs, it should be simple to do everything you want with a few lines of code, by customising the original navcontroller's navbar.
You would not manage a navigation bar in interface builder. Also, you would not try to set the navigationBar property of the navigation controller.
To make changes you would make changes to the navigationItem property of the navigationBar
[self.navigationController.navigationBar setItems:newNavItems];
You can also make other changes to the navigationBar such as setting a background image or making it translucent
self.navigationController.navigationBar.translucent = true;
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:barMetrics];

Is there another way than presentModalViewController to show a UITabBarController on just part of the screen?

I have a UITabBarController displaying a number of settings-screens in my app. I want them to be shown on just a part of the screen for layout reasons. In fullscreen, the lists become unreadable (too wide), there are just a few controls per page making the page feel very empty, and the tabbar buttons are far away from the content (Fitts law).
Using presentModalViewController with the UIModalPresentationFormSheet style gives me the size I want. I do this on top of an empty background, since in my case it doesn't make sense to display anything behind it. The "real" working area is displayed with another presentModalViewController in fullscreen mode on top of it all.
This works but feels like a hack. One problem is, I can't make the background behind the settings dialog move in the transition to fullscreen with the UIModalTransitionStyleFlipHorizontal style.
TL;DR
Can I embed a UITabBarController non-fullscreen in another "background"-view? I can't find any information of how I would do this.
Can I embed a UITabBarController non-fullscreen in another "background"-view? I can't find any information of how I would do this.
Why don't you try it out?
Create a container view of the size you want the tab bar controller to have.
Create the tab bar controller.
[containerView addSubview:tabBarController.view];