I have few UIViewControllers embeded in NavigationController, everything is cool when it comes to change screen titles, button titles, hiding/showing navigation bar (top bar) or toolbar (bottom bar), but - I cannot force toolbar buttons to have this animated shadow when pressed, as navigation bar buttons have. What's more, toolbar buttons are as black as toolbar - shouldn't button be slightly lighter color than toolbar?
I hope it's clear, because I couldn't find it nor even come up with reasonable title
If you want a black bar (navigation or toolbar), set its barStyle to UIBarStyleBlack in addition to or instead of tinting it black. This lets it know that the buttons should be tinted differently than if the bar was any other color.
I am not able to understand you whole problem but for the toolbar problem you can give those buttons different colors and also can give an effect of changing color of button which is clicked
UIBarButtonItem *toolBtn = [[UIBarButtonItem alloc] initWithTitle:#"Share and Upload"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(your_Target)];
toolBtn.tintColor = [UIColor redColor];
Now suppose toolBtn is your first button in toolbar and on click of it you want to change its color then in your target function
-(void)your_Target{
UIBarButtonItem *button1 = [[your_Toolbar items] objectAtIndex:0];
button1.tintColor = [UIColor brownColor];
// or you can simply loop all toolbar buttons and change the color of only clicked one and for rest keep it default
}
Hope this will help you.. and sorry for my bad english :)
I have an iphone application in which in a button click i am showing a view like an alertview.at that time i want my remaining views (background) to be a shadow one,like as we see the background when showing the alertview.Can anybody help me to achieve this?
This is rather simple, make your new view a sub view of a view that covers the full screen with alpha set to 0.7 or something and the color of your choosing, then present this view and everything behind should be darkened.
You can just alloc a view with the main view's frame, and set the background color to gray, when you click the button, add this view and then add the specified view or you can add the specifed view in this gray view....
You can simply add a UIView as a subview of your controller view. Set black as the backgroundColor of it with an alphaValue between 0 and 1. Remember to set the frame equals to the viewcontroller view
In your alertview callback, just remove the view.
When a button click for showing a view:
-(void)yourButtonAction
{
[self.view setAlpha:0.3];
}
Now when removing view like an alertview.
[self.view setAlpha:1.0];
Best way is to create a new image (black translucent background patch) and add in the background of the superview and set the background color of superview as clearcolor.
I have a UIWebView that is sandwiched in between a UINavigationController (top) and a UIToolbar (bottom). When the user taps twice on the UIWebView, I want to smoothly animate the top and bottom bars to hide. However, when I use this code (and several other different variations of this concept), the bar hides fine, but sometimes (sometimes not) the UIWebView content scrolls up 20-30px:
[self.navigationController setNavigationBarHidden:YES animated:YES];
It works sometimes, and then other times it doesn't. I just want to be able to smoothly hide/unhide both bars, changing the UIWebView size to full screen/not full screen as I go.
Anybody done this? Or know what is going on here?
make your UINavigationBar translucant
self.navigationController.navigationBar.translucent = YES;
in your viewWillAppear method.
I have UITabBarController in my app.
In a particular view I want to hide the tabbar and display the content up to the below line.
For that I used the code in the view
-(void)viewWillappear{
[self.tabBarController.tabBar setHidden:YES];
}
It depends what your content is, but if it's inside a container, like a UIView, you can change the autoResizingMask to be
myView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
and it should do the right thing.
I am using a navigation controller, and I have the style set to :
navController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
But when I run my program, the navigation controller looks like it is on top of a white background, not my background. When I push a controller, left or right, all my view, the current one, shifts to the top exactly the size of the navigation bar. And it is there where I can see my background through the navigation controller bar. Any ideas? When my barStyle is set to opaque, everything looks fine. I was thinking on setting my view frame a negative 'y' value, but I think there should a more elegant way.
I believe the UINavigationController assumes that your controller view frames don't include the area beneath the navigation bar.
UIBarStyleBlackTranslucent is more often used for UIToolbar, so Apple probably didn't make it easy to use it nicely with UINavigationBar. You'll probably need to abandon the UINavigationController, or start hacking the frames (careful with rotations), if you want to reliably render under the bar area.
Also, if your intention is to hide the navigation bar after a few seconds, you'll have a much easier time if you make it fade out (like the Photos app) instead of trying to slide it up (like Mobile Safari). Trust me on that one... that took me a lot of time to learn the hard way.
Simply use a transparent background image, and translucent = YES to allow the content to flow below the bar. Works on iOS 5 / 6. Add in viewDidLoad.
self.navigationController.navigationBar.translucent = YES;
UIImage * backgroundImage = [UIImage imageNamed:#"spacer.gif"];
[self.navigationController.navigationBar setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:UIBarMetricsDefault];
I attached the spacer.gif image here, a single 1px x 1px transparent image.
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.169 green:0.373 blue:0.192 alpha:0.9];
self.navigationController.navigationBar.translucent = YES;
Note:
Don't use self.navigationBarStyle and self.navigationBarTintColor to change.
Add the last two statements to your viewDidLoad.
I ran into this same problem (in 3.1.3) and while you can't set the bar style after the navigationBar has already been setup you CAN set the tintColor and translucent values whenever you like:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationController.navigationBar.translucent = YES;
Will create the 'blackTranslucent' bar, I change the navigationBar look when I push certain view controllers onto the stack.
I had the same problem, and I solved it by making the background of the root view the same as my view. The white area behind the navigation bar turned out to be the root view.
The navigation controller offsets the coordinate sytem of all it's subviews so they draw below the navigation bar.
Extend your view's frame into the negative y domain for it to draw under the navigation bar.
You need to set the barstyle in your info.plist file for it offset everything correctly.
However, I haven't tried it since the 2.1 f/w was released, but when I tried this in 2.0 I found that the setting was lost after a rotation from portrait to landscape.
try to use this, may be it will helpful.
_topToolBar.barStyle = UIBarStyleBlackTranslucent;
_topToolBar.alpha = 0.3;
I had a same problem.I solved!
ImageViewExtendController *detailImageController = [[ImageViewExtendController alloc] init];
[detailImageController loadImage:url];
[self.navigationController pushViewController:detailImageController animated:YES];
If you set your nav controller's navigationBar to transparent in your App delegate early enough (It worked for me before adding the nav controller to the window), it will automatically shift your view up underneath the navigation bar.
Unfortunately it does not also shift your view underneath the status bar. Sad, it looks like you need to implement your own version of UINavigationController. Luckily, it's not too bad as UINavigationBar is pretty reusable.
Try this:
self.tabBarController.tabBar.superview.backgroundColor = [UIColor blackColor];
Change the Extend Edges options in child viewControllers
As for example, in xcode editor, go to your first viewcontroller child and unset the options:
Extend Edges;
Under Top Bars;
Under Bottom Bars;
Under Opaque Bars;
This way your child ViewController will not layout starting below the status bar of the navigation controller, neither the tabbar or the toolbars
hope it may help anyone