I am experiencing strage issue on iOS7. The navbar just after first time user gets to main screen:
The navbar after simple push/pop
The setup in storyboard:
It's setup for logout button, the same is set up for search button.
There's no dealings performed with navigationItem in code. Any suggestions?
EDIT For sure i can do the trick with
- (void)viewWillAppear:(BOOL)animated
{
self.leftBarButtonItem.tintColor = [UIColor whiteColor];
self.rightBarButtonItem.tintColor = [UIColor whiteColor];
}
But i don't understand the reason of losing tint. And this is the question, not what to do.
Since iOS7 you need to set the tintColor for the navigationBar to change the buttonItems color:
self.navigationBar.tintColor = [UIColor whiteColor];
Or you can set it from the storyboard as well.
For more explanation check this SO answer.
Related
I am trying to modify navigationBar's appearence by setting it's tinkColor & barTintColor
start up with doc on page https://developer.apple.com/documentation/uikit/UINavigationBar?language=objc
I tried to modify the navbar on the [viewDidLoad] hook of my ViewController as follows
self.navigationController.navigationBar.translucent = NO;
UIColor *barColor = [UIColor ColorA];
self.navigationController.navigationBar.barTintColor = barColor;
UIColor *backButtonColor = [UIColor ColorB];
self.navigationController.navigationBar.tintColor = backButtonColor;
But then the back button then disappeared and the change of barTintColor dosen't seem to be effective
What am I doing wrong?
Weird behavior.
check please title of previous viewcontroller
check please if there is something like(hiding back button somewhere):
self.navigationItem.leftBarButtonItems = []
self.navigationItem.hidesBackButton = true
double check color for backButtonColor(be sure that barColor != backButtonColor). Try some native color: [UIColor red]
I have a ViewController with a Navigation Controller before it, that has a TableView and other elements inside. The tableView has also a Search Bar, and in the scene, besides the main ViewController I have a Search Display Controller.
The functionality is working, but I have the following UI issues:
Although my main view has black background colour(and most of the elements have black background colour), when I drag the tableView downwards there appears some white space.
I also have the following initial setup for UI
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.view.backgroundColor = [UIColor blackColor];
self.tableView.backgroundColor = [UIColor blackColor];
self.searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.searchDisplayController.searchResultsTableView.separatorColor = [UIColor blackColor];
self.searchDisplayController.searchResultsTableView.separatorInset = UIEdgeInsetsMake(0, 12, 0, 12);
[self.searchDisplayController.searchResultsTableView setBackgroundColor:[UIColor blackColor]];
[self.searchDisplayController.searchContentsController.view setBackgroundColor:[UIColor blackColor]];
self.searchDisplayController.searchBar.barStyle = UIBarStyleBlack;
self.searchDisplayController.displaysSearchBarInNavigationBar = NO;
}
When I search for a result, and drag the table upwards after the Search Bar, there is a small place where the table view is visible.
Any ideas how can I fix this :(?
Edit update:
Both were solved removing the Search Bar from the TableView. After this another issue came that the animation of Search Display Controller wasn't updating the Search Bar. this was solved with the following post:
UISearchBar animation issue
You have to set UIView background color to black (not just UITableView color).
You have to position your table view below UISearchBar, you can do this either programmatically or via IB. I recommend second option. Pretty easy.
Im using:
#define colorApp [UIColor colorWithRed:254/256.f green:64/256.f blue:89/256.f alpha:1.0]
Inside the customSearchView init:
[self setBackgroundColor:colorApp];
searchBar = [[UISearchBar alloc] initWithFrame:frame];
searchBar.barTintColor = colorApp;
[self addSubview:searchBar];
Getting the next result:
I need the searchBarTint color to be the same as the navigation. Translucent doesn't seem to make the work.
I came up with the fix soon after I posted the question.
In case anyone ever faces this problem I used
[self.searchDisplayController.searchBar setBackgroundImage:[UIImage imageNamed:#"pinkBar.png"]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
It seems backgroundColor and barTintColor aren't taking colors same way as the navigation for a UISearchDisplayController since iOS 7. But adding an image with that color just resolves that.
I know it's just a quick fix but it helped me and could help others as it is a minor visual issue.
I met with a problem. At first some code from AppDelegate.
- (void)HideMainNavigationBar{
navigCtrl.navigationBarHidden = YES;
}
- (void)ShowMainNavigationBar{
navigCtrl.navigationBarHidden = NO;
}
navigCtrl is my navigation controller.
In my other View Controller I need hide my navigationBar and then show it, to display it correctly.
- (void) moviePlayerWillExitFullScreen:(id)sender {
NSLog(#"exitfullscreen");
AppDelegate *ptr = [AppDelegate SharedAppDelegate];
[ptr HideMainNavigationBar];
[ptr ShowMainNavigationBar];
}
After that, instead of my custom tabBarButton I saw Back button:
After tap ob Back button, it disappears, and I see my navigationBar again with my custom button. This 'bug' was detected in iOS 5.1, on iOS 4.3.2 everithing is ok.
This makes me crazy, help please.
P.S. I know, that I can use:
self.navigationController.navigationBar.frame = CGRectMake(0, 20, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);
to display navigationBar correctly, but i need to show/hide navigationBar to hide it, while rotating VideoPlayer.
Any ideas?
Wait your answers, thanks.
So, after some manipulations I decided simply to set alpha to my navigationBar.
if (SYSTEM_VERSION_LESS_THAN(#"5"))
[ptr HideMainNavigationBar];
else self.navigationController.navigationBar.alpha = 0;
I hope it would be useful for someone. See ya.
I just have posted code dedicated on UINavigationBar appearance management on github. check out RRViewControllerExtension, it will solve your problem gracefully.
I have changed my navigation bar color via the following code
navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:#"faf6f5"];
The code worked but the text color also needs to be changed (see screenshot below). Also the refresh button logo on the right is affected as well
The same issue occurs if I navigate to another page in the stack
Question: How can I change the color of the
title text
Back button text and
right bar button icon color?
After I changed the background color of the navbar?
In iOS 7, just use:
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName : [UIColor whiteColor]};
Change [UIColor whiteColor] with whatever text color you want
For the title here's the way:
iPhone Navigation Bar Title text color
And for the custom buttons here's the way:
adding buttons to ui navigation controller bottom bar
To change text color:
_navController.navigationBar.titleTextAttributes
= #{UITextAttributeTextColor : [UIColor blackColor]};
Adding refresh button and color it:
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:#selector(reload)];
[button setTintColor:[UIColor blackColor]];
self.navigationItem.rightBarButtonItem = button;
Variables that effect navigation bar background:
_navController.navigationBar.backgroundColor = [UIColor whiteColor];
_navController.navigationBar.tintColor = [UIColor whiteColor];
_navController.navigationBar.translucent = NO;
I just put together a simple UIViewController subclass that adds a customizable back button that allows you to change text colors. It basically adds some willAppear/willDisappear logic to animate the back button the way the UINavigationController does while using the leftBarButtonItem property. You might extend this to also do the rightBarButtomItem as well.
https://github.com/typeoneerror/BBCustomBackButtonViewController