Appear obscure line after statusBar - ios

I have a problem with navigationBar. It is transparent. After scrolling appear obscure line under statusBar. What is it?
Method for transparent:
- (void)makeNavbarTransparent:(BOOL)transparent {
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
[self.navigationController.navigationBar setTranslucent:YES];
}

Related

iOS Make Navigation Bar transparent, while at the same time, preventing view to slide under Navigation Bar

My problem is, when I set the navBar to transparent with this code:
[[self navigationController] setNavigationBarHidden:NO animated:YES];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
[self.navigationController.navigationBar setTranslucent:YES];
.. the navigationbar hides the top of the viewcontroller's view:
I tried to prevent this with:
self.edgesForExtendedLayout = UIRectEdgeNone;
... but then, the navbar is not transparent anymore.
How can I achieve both?

How to make UINavigationBar fully transparent or gone like this only title and UIBarButtonItem could be seen

As you can see, the UINavigationBar is fully transparent. Only the title and UIBarButtonItem is visible. And the status bar has the same colour as UITableView's background colour. Right now, I have finished to make the table view and cell has the same effect as the pic. But how to make the navigation bar and the status bar has the effect too?
Try this one
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
Try this !
[self.navigationController.navigationBar setBackgroundColor:[UIColor clearColor]];
[self.navigationController.view setBackgroundColor:[UIColor clearColor]];
[self.navigationController.navigationBar setBarTintColor:[UIColor clearColor]];

Navigation Bar Appearance Settings don't apply constantly

I tried to customise my UINavigationBarController:
// Customize NavBar Appearance
[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor whiteColor],
NSFontAttributeName: [UIFont fontWithName:#"Lato-Light" size:35.0]}];
// Set NavBar Bottom Border to White by adding a view with height 1
UINavigationController *navBarController = [[self.tabBarController viewControllers] objectAtIndex:0];
CGFloat navBarWidth = navBarController.navigationBar.frame.size.width;
UIView *navBottomBorder = [[UIView alloc] initWithFrame:CGRectMake(0, kNavBarHeight- 1, navBarWidth, 1)];
[navBottomBorder setBackgroundColor:[UIColor colorWithWhite:255.0f alpha:0.25f]];
[navBottomBorder setOpaque:YES];
[[UINavigationBar appearance] addSubview:navBottomBorder];
The problem I encounter is, that this added subview randomly disappears when clicking through my tab bar items. Sometimes it is visible perfectly, sometimes only the appearance settings for text and font color are presented. By the way: These are always correct. Only my subview is not showing up anymore after the first boot and switching the tabs.
When I use "insertSubview" instead of "addSubview" it seems to work. So I could imagine, that the navbar is being drawn over my added subview?

Remove Custom Nav Bar on Email Sheet

I have this code in my App Delegate:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"Nav Bar.png"] forBarMetrics:UIBarMetricsDefault];
This works great, but I use the MFMailComposeViewController and I want it to have the default NavigationBar appearance.
How do I do that?
EDIT:
I tried this code:
[[UINavigationBar appearanceWhenContainedIn: [MFMailComposeViewController class], [UIViewController class], nil] setBackgroundImage:[UIImage imageNamed:#"Textured Background.png"] forBarMetrics:UIBarMetricsDefault];
I've also tried having only this code. Nothing changes. Default Nav bar, including with the Mail View Controller.
I think it could be something with the appearanceWhenContainedIn:. Does anyone know what MFMailComposeViewController would be contained in?
I figured it out! Here's the code:
[[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
MFMailComposeViewController *emailVC = [[MFMailComposeViewController alloc] init];
//the rest of the implementation goes here...
[self presentViewController:emailVC animated:YES completion:nil];
Then, I set the nav bar appearance back to normal here:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"Nav Bar.png"] forBarMetrics:UIBarMetricsDefault];
[self dismissViewControllerAnimated:YES completion:nil];
}
You can try this:
[UINavigationBar appearanceWhenContainedIn: [MFMailComposeViewController class], nil]
Which means all navigation bars contained in a MFMailComposeViewController class
From the docs: UIAppearance
This will return the appearance proxy so you can modify it like this:
[[UINavigationBar appearanceWhenContainedIn: [MFMailComposeViewController class], nil] setBackgroundImage:myImage];
Hope that helps.

How to customize UINavigationBar only for certain view controller

[[UINavigationBar appearance] setBackgroundImage:gradientImage44
forBarMetrics:UIBarMetricsDefault];
Would customize UINavigationBar
Say I have a class
BGImageBookController
I want UINavigationBar on top of BGImageBookController to have a different background. How would I do so?
I did this in viewDidload
- (void)viewDidLoad
{
[super viewDidLoad];
[[UINavigationBar appearanceWhenContainedIn:[BGImageBookController class], nil] setBackgroundImage:[UIImage imageNamed:#"sushi_eating_cat"] forBarMetrics:UIBarMetricsDefault];
}
no effect
This is your code:
[[UINavigationBar appearanceWhenContainedIn:[BGImageBookController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
You just call setBackgroundImage:forBarMetrics: in the viewDidLoad method of the BGImageBookController.

Resources