navigation bar too big after adding custom background image - ios

I'm trying to customise the navigation bars throughout my app.
The navigation controller has been created in IB.
I used the following code to add a custom image to the bar. The image is 320 x 44 points.
This code is in the AppDelegate in applicationDidFinishLaunchingWithOptions:
UIImage *navBackgroundImage = [UIImage imageNamed:#"Nav Image.png"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
The problem is that on the simulator, the bar now covers half the screen! And covers up a load of content. Ive tried messing around with the image dimensions in Photoshop and it helps, but their must be an easier way than messing around and rebuilding with trial and error?!!
Are there any convenience methods that set the size of the nav bar?
Any help much appreciated!!

Maybe it is a layer Rasterization issue :
check if there is :
layer.shouldRasterize = YES;
layer.rasterizationScale = [UIScreen mainScreen].scale;
somewhere in your code and try commenting those lines.
(these lines are often linked to shadows to improve the performance when displaying them).

A quick solution is to go to the NIB file and select UINavigationControler -> Size Inspector -> TurnOff Autoresizing.

Related

How to set a UINavigation size to fit the background image size?

I've set my UINavigationBar background image to some image, like this:
UINavigationBar *navBar = self.navigationController.navigationBar;
UIImage *image = [UIImage imageNamed:#"Menubar.png"];
[navBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
but I cant really see the whole image since its bigger than the default size on a UINavigationBar.
So two things please:
How to set a UINavigation size to fit the background image size?
I dont want to see the battery and time bar in the background, so my image will cover it.
It's not possible to set UINavigation size (take a look at this question), you have to fit the background image instead
It's impossible to cover the status bar, but you can easily hide it. See the example here
you can easily remove status bar using info.plist file
just addRow and write "Status bar is initially hidden" and set value "YES"
end check to navigationBar
iOS. How to change UINavigationBar height and change frames of the others subviews at once?

iOS 7 Views layout & Translucency effect

I have several issues. Basically I want to rebuild this view:
While rebuilding this I m getting weird behaviors. Let's get started:
First my progress so far:
Device Screenshot:
My ViewControllers structure (Storyboard):
Well step by step:
Navigation Bar
I tried to make it transparent and I think it would normally work, but as you see in my structure I put a UIView over my background-imageview (Big profile picture) that simulate a alpha overlay. As you can see in my Device-Screenshot the Navigation Bar cuts of the overlay. So any idea how to fix that?
Code:
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBarHidden = NO;
View Positioning
As you can maybe see only the background-profile-image goes behind the Navigation Bar, but the rounded image and text-labels have the same top margin from the Navigation Bar. Shouldn't it be also effected by the translucency of the Navigation Bar? Any hints would be great.
Also the UIView that act also as alpha overlay don't go that much down to fill the image. Even I set all the exact same heights.
You can't see it on these images, but the View that contains all the counting labels overlaps the background-imageview (The background-imageview shouldn't even go that far down, very strange!).
You guys are my last hope. Else I have throw this awesome design ;(
Your dim view should be attached to the top of the superview and not the top layout guide.
You could post your constraints if you want more help.
Its looking good. You're almost there! The problem might be that you have a UIScrollView inside your view controller's view and that it is respecting the content insets applied by a navigation controller (assuming there is one because I spy a navigation item in your storyboard).
Try setting this on your view controller:
self.automaticallyAdjustsScrollViewInsets = NO;

iOS 7 Navigation Bar

Trying to use a background image that is bigger that than the regular size with some details that hang off the bottom.
So I'm doing this to set the image:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"nav_bar_home.png"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setClipsToBounds:NO];
[self.navigationController.navigationBar setTranslucent:NO];
And It's still getting clipped.
Some other things I've tried:
Splitting the image up in Photoshop and setting the top 44points (the size that logs out when I log out the navigationBar's frame) to the backgroundImage and the rest to the shadowImage.
From memory this worked fine in iOS 5, 6.
Is there a nice way to do this now? Thanks :)
I'm pretty sure that I remember from one of the WWDC 2013 videos that what you were doing in iOS 5 and 6 (nav bar background view larger than the nav bar "with some details hanging off it") was considered wrong and they are no longer allowing it.
However, if you are supplying your own background image you can add a custom shadow image.

NavigationBar clipping background image in iOS7 ;ClipsToBound:NO not working

I have set a background image slightly bigger than the navigationBar.The image is 55px in height.[I want a banner looking image with ribbon at the bottom of nav bar]
It was working ok in iOS6.
But in iOS7, its getting clipped by itself.
I tried setting
[self.navigationController.navigationBar setClipsToBounds:NO];
It's still getting clipped.
Can't I have a bigger background image without getting clipped?
this is due to Ui navigation bar is 64 point in ios7 that why this create problem.
refer this link https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Bars.html refer table 5-1 that is give you idea that for resizable image what are the change in new ios7
you can use UIBarPositioning propety to solve your problem not sure but that may help you
refer this link for more info related to UIBarPositioning
https://developer.apple.com/library/ios/documentation/uikit/reference/UIBarPositioning_Protocol/Reference/Reference.html#//apple_ref/occ/intfp/UIBarPositioning/barPosition
Edited
also try by set this flag
navigationBar.translucent = NO;
for more info refer this link
iOS 7 UINavigationBar - UIView layout issue
The image is not getting clipped, it is most probably just too small.
The UINavigationBar is 64 points in iOS 7, so the 55px image will be too small, especially considering the retina resolution where 128px would be needed.
set the delegate of your navigation bar to your view controller, and return UIBarPositionTopAttached in delegate method. return the position which you want to see
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
https://developer.apple.com/library/ios/documentation/uikit/reference/UIBarPositioning_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIBarPositioning

UINavigationBar right button too tall

I'm using custom images for UINavigationBars and UIToolbars. The problem i'm having is on 1 of my views that uses a UINavigationBar, the right button appears too tall
On the views that use a UIToolbar (modal views so no Nav bar) they look fine
What could be causing the button to be too large? I've tried adding the button in IB and also using code. Then set the image like this
UIImage *barButton = [[UIImage imageNamed:#"ButtonBlue"] resizableImageWithCapInsets:UIEdgeInsetsMake(6, 8, 6, 8)];
[self.connectButton setBackgroundImage:barButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Thanks
Create a smaller button. You can do this in Preview - resize it. Make sure you have #2x sizes too. T cannot recall the recommended size for theses images - it's something like 30 points or so (search and you'll find it for sure).

Resources