This does not work
[self.navigationController setNavigationBarHidden:YES animated:YES];
when I have this barstyle
rootNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Is it any reason why it shouldn't animate away? Are there any fixes to this?
EDIT
This is NOT working:
[rootNavigationController.navigationBar setBarStyle:UIBarStyleBlack];
[rootNavigationController.navigationBar setTranslucent:YES];
The UIBarStyleBlackTranslucent is deprecated. Use UIBarStyleBlack and set the translucent property to YES instead.
Related
In my application i want to change the tab bar controller color,How to assign a custom color to the tab bar controller lik uinavigation bar in ios6?Can any one give me some refrences?
Put this on app delegate:
UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController;
tabBarController.view.tintColor = [UIColor redColor];
It's better than the first answer because it also changes the edit view tint color.
You can use the setTintColor option as described
[tabbarController.tabBar setTintColor:[UIColor greenColor]];
or you can set the background image
[tabbarController.tabBar setBackgroundImage:[UIImage imageNamed:#"tab_bg.png"];
if your TabBarController is defined int the AppDelegate you may need additional coding to access it.
First to set the background image
[[[[(UITabBarController *)[[(AppDelegate *)[UIApplication sharedApplication].delegate window] rootViewController]tabBar]setBackgroundImage:[UIImage imageNamed:#"tab_bg.png"]]]];
Second to set the tintcolor if required
[[[[(UITabBarController *)[[(AppDelegate *)[UIApplication sharedApplication].delegate window] rootViewController]tabBar]setTintColor:[UIColor redColor]]]];
dont forget to import your AppDelegate.h file.
You can use this call
tabbarController.tabBar.tintColor = [UIColor redColor];
To change only tabBar color, you can achieve by this:
tabbarController.tabBar.tintColor = [UIColor redColor];
But, for more, you need to create Custom TabBar and can do with it like color change, custom tabbar icon changes, etc.
Hope, it will be helpful to you.
Cheers.
Approach that worked for me (tested in iOS6) is:
[[UITabBar appearance]setTintColor:[UIColor redColor]];
in AppDelegate.h file in method application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions. Try this if it's still actual. I see the question still stays unsolved.
I have a MFMailComposeViewController that I'm presenting and I want to clear the image from the navigationBar.
On iOS 5, this works fine:
[self.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
But on iOS 6, this has no effect. How could I do this?
Thank you!
You jus hide the navigation bar..
self.navigationController.navigationBarHidden = YES;
or
[self.navigationController setNavigationBarHidden:YES animated:animated];
I'm sorry, I have to answer my own question. I made an error: I had set the UINavigationBar app-wide by doing
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"bar01.png"] forBarMetrics:UIBarMetricsDefault];
which had the effect of causing all navbars to have the bar01. Removing this line made it so that the MFMailComposer navbar was the default color with no need to nil out the image.
I have a problem with the display of my popover. After initWithContentViewController: and presentPopoverFromBarButtonItem:permittedArrowDirections:animated: it cuts corners of the navigation bar. How should I fix it?? Thanks.
This is the code I'm using
NavContr *nav = [NavContr new];
nav.navigationBar.backgroundColor = [UIColor redColor];
UIPopoverController *tempPop = [[UIPopoverController alloc] initWithContentViewController:nav];
[tempPop presentPopoverFromBarButtonItem:mainButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
EDIT: I have resolved this problem:
+ (void)configure:(UINavigationController *)navController {
UINavigationBar *navigationBar = navController.navigationBar;
UIView *contentView = nil;
for (UIView *view in navController.view.subviews) {
if ([[NSString stringWithFormat:#"%#", [view class]] isEqualToString:#"UILayoutContainerView"])
contentView = view;
}
// setting frame to navigation bar and content view
[navigationBar setFrame:CGRectMake(navigationBar.frame.origin.x, 0, navigationBar.frame.size.width, navigationBar.frame.size.height)];
[contentView setFrame:CGRectMake(contentView.frame.origin.x, 0, contentView.frame.size.width, contentView.frame.size.height + navigationBar.frame.size.height)];
[navController.view bringSubviewToFront:contentView];
for (UIView *customView in contentView.subviews)
customView.frame = CGRectMake(customView.frame.origin.x, customView.frame.origin.y + navigationBar.frame.size.height, customView.frame.size.width, customView.frame.size.height);
[contentView addSubview:navigationBar];
[contentView bringSubviewToFront:navigationBar];
}
This is probably because you have no root view controller, or are otherwise fiddling with the navigation controller in ways it was not meant to be played with. This is how you ought to be setting up the popover:
MyCustomViewController *viewController = [[UIViewController alloc] initWithNibName:#"MyCustomViewController" bundle:nil]; //or storyboard or whatever
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController]; //you should have a root view controller before displaying the popover
tintColor = [UIColor redColor];
UIPopoverController *tempPop = [[UIPopoverController alloc] initWithContentViewController:nav];
[tempPop presentPopoverFromBarButtonItem:mainButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO];
There are a few very important things going on here:
Your navigation controller should have a root view controller before you display it.
This code is using a standard UINavigationController instance. According to the documentation, you should not subclass UINavigationController, nor should you try and reinvent the wheel. Apple has created a complex and comprehensive framework, UIKit, that you can use to build amazing apps. If you try and step outside the box, you'll be creating an awful lot of work for yourself without any appreciable benefit.
This is using the tintColor property of the UINavigationBar class. If the tint is insufficient for your UI, you can also set the background image manually (refer to the docs).
If you want to make a popover with a navigation controller, use the built-in UINavigationController class. Don't subclass it and don't reinvent it. To customize the appearance of the navigationBar, use the UI_APPEARANCE_SELECTOR methods in the UINavigationBar class.
I get the solution before add CALayer the UIPopOverController shows like
after adding below lines in table view class i get the following UIPopOverController
#import <QuartzCore/QuartzCore.h>
CALayer *imageLayer2 = self.tableView.layer;
[imageLayer2 setCornerRadius:-20];
[imageLayer2 setBorderWidth:1];
Try it in your project may be it works!!
Thanx
I have tried & replicate the issue you are facing, made some R&D. It's due to the line of code below :
nav.navigationBar.backgroundColor = [UIColor redColor];
While you set the background color of the navigation bar it will behave weird due the native shape of the pop up. Try and remove the below line, you will definitely have issue resolved.
If you are specifying the Rect where the popover appears, we've found that using decimals can result in weird distortions like that. Be sure you're using whole number for origin and size.
I have a view being displayed modally and, before I display it, I set it's background color to transparent...
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
MyViewController_iPhone *myVC = [[MyViewController_iPhone alloc] initWithNibName:#"MyView" bundle:nil];
[myVC.view setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.0]]
[[self navigationController] presentModalViewController:myVC animated:YES];
[myVC release];
}
As the view animates up onto the screen, the background is transparent, but as soon as it finishes animating upward, the view's background goes back to the original opaque white color, why?
Thanks in advance for your help!
According to this post Transparent Background with a Modal UIViewController it cannot be done. What are you trying to end up with?
This link seems to describe what you're trying to achieve. http://doganberktas.com/2010/05/18/adding-transparent-modal-view-programatically-iphone/
I am trying to copy the UIImagePickerController as best as I can. If I do that in a regular UITableViewController it shows the StatusBar translucent and you can see the content behind it (just like in apples UIImagePickerController).
self.wantsFullScreenLayout = YES;
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
But if I present a new UIViewController (with a UINavigationController as a subview) as a modalViewController:
[self.navigationController presentModalViewController:myImagePickerController animated:YES];
then the StatusBar becomes opaque, it still has this dark grey color but you can't see anything behind it. And yes I have wantsFullScreenLayout, etc. in myImagePickerController viewDidLoad() method.
How do I fix this so It behaves like apples UIImagePickerController, a modalView with translucent StatusBar?
Try presenting it from the window.