I am developing in Xcode 5, and issue happens only in iOS versions below iOS 7. I have to keep status bar visible. I am using
self.wantsFullScreenLayout= YES;
But my view is still appearing beneath the status bar.
How can i fix this so the view is not covered by the status bar?
You need to set Delta of your UIViewController 's view.
Switch Story board to ios6.1 or later from utility area (1st item).
Then select view of your UIViewController and in size inspector menu in utility area there will be delta section below frame. There will be triangle before every delta. Change Triangle y to 64 (you should be on "ios6.1 or later" of your storyboard).
This means when storyboard is opened in ios7 then your UIViewController's view will start from 64 automatically . 64 is UINavigationbar height + UIStatusbar height.
If your UIViewController dont have UINavigationBar then Delta y = 20,(you should be on "ios6.1 or later" of your storyboard).
Once you change delta's in one ios it will automatically change its opposite.
If you need help on Deltas visit : Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
What iOS version are you targeting?
Do you want your view under the status bar or the status bar removed completely? If you want to get rid of the status bar
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
Are you targeting iOS 7? if so you can use this to hide the status bar
- (BOOL)prefersStatusBarHidden
{
return YES;
}
Related
I have a custom navigation bar that worked well until iOS 11. It appears smaller than it should and seems to ignore the status bar height or something.
I set the whole thing programmatically and the height is set to 64.
have you tried to disable (untick) safe area?
I want to make a navigation bar that changes height in it's detail view just like the messages app in iOS 10. How can I do that?
Edit:
I am looking to change the height dynamically. SizeThatFits() Permanently changes the height.
If you are trying to do something else that requires the navigation bar to be resized, that's not supported. iOS 11 and Above
Community bug reports
I have a UIViewController subclass which when I run the app on iOS 7, the status bar shows on top of my view. Is there a way to avoid this? I do not want the status bar to be hidden. Is there a way to show the status bar above my app. I present my view using presentViewController. Please guide what I am missing?
In Xcode, In storyboard there is an option of iOS6/7 delta. set delta Y to 20 pixel of your view, to make compatible with iOS7.For this you have to disable auto layout, you can use auto resizing.
This is quite common issue. Starting from iOS 7 Status Bar is a part of the controller's view. Apple even have added special attribute of UIView in the Interface Builder: iOS 6/7 Deltas. To fix your problem and make your view look the same in different iOS versions, go to Size inspector and set Delta Y to 20.0.
I want add 20 points margin to my navigation bar. I need it because I want another background color under status bar as youtube did:
I found
iOS Developer library says: Status bar background appearance provided by the window background, if using UIBarPositionTop.
I found solution for toolbar, but I can't move my navigation bar inside navigation view controller. I just set UIBarPositionTop for my navigation bar, but it changes nothing.
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
NSLog(#"position method called");
return UIBarPositionTop;
}
I still see the gray background of status bar instead of white.
Is it possible to do it with a navigation bar or should I use a view with a toolbar?
(XCode 6, development target 7.0+, sdk 8.0, autolayout)
UPDATE: ANOTHER WAY TO RESOLVE PROBLEM
I read this question
and understood, that there is no need to add margin. I added view with background color I need over my navigation bar controller and it resolved my problem.
When you are adding your UIView to the UIWindow, you should change the UIViews size to not underlap the title bar. How to do this is well documented in this post:
Offset on UIWindow addSubview
I hope i understood correctly, look in size inspector, ios 6/7 deltas.
Check this link for an explanation:
Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
I have added a custom titleView to my UINavigationItem, and that contains a view that is intended to be under the status bar. It looks fine, and when I push another viewcontroller and that transitions away in the standard right-to-left animation it looks fine. However, when I [self.navigationController popViewControllerAnimated:YES] it clips the top of this view until the animation is finished. Please see attached image for a better explanation of the problem.
It's only until after the pop-animation is done that it looks normal again. I have tried everything I can think of. Setting cropsToBounds to NO on all the views the viewController AND navigationBar. I've tried also layer.masksToBounds and just about every property that sounds familiar. I've added a timer that prints the frame rectangle of the navigationBar and the custom titleView and it doesn't appear that they change anything.
Does anybody know what I'm doing wrong?
Two ways to do it :
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)]) { // if iOS 7
self.edgesForExtendedLayout = UIRectEdgeNone; //layout adjustements
}
Or
You need to set Delta of your view controller. Switch Story board to ios6.1 or later from utility area (1st item). Then select view of your Vc and in size inspector menu in utility area there will be delta section below frame. There will be triangle before every delta. Triangle y to 64 (you should be on ios6.1 or later of your storyboard).
If you need help on Deltas visit : Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?