Make navigation bar transparent regarding below image in iOS 8.1 - ipad

I try to set my navigation bar transparent regarding a image below this, something like the following image :
I tried the solution in transparent navigation bar ios but I don't get the above result, I get only the icon on the left but without any color in the navigation bar, completely transparent. But if I set a background color the transparency disappears at all.
There is any way to set a color in the navigation bar and make it transparent??
Thanks in advance.

just checked on the 8.1 simulator and got very similar result to your picture
let bar:UINavigationBar! = self.navigationController?.navigationBar
bar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
bar.shadowImage = UIImage()
bar.backgroundColor = UIColor(red: 0.0, green: 0.3, blue: 0.5, alpha: 0.3)
main point here is background color with alpha.
Check attached image, maybe I missed something?

To set this style globally, use the UIAppearance APIs. In AppDelegate's application:didFinishLaunchingWithOptions: add the following code:
// Sets background to a blank/empty image
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default)
// Sets shadow (line below the bar) to a blank image
UINavigationBar.appearance().shadowImage = UIImage()
// Sets the translucent background color
UINavigationBar.appearance().backgroundColor = UIColor(red: 0.0, green: 0.3, blue: 0.5, alpha: 0.3)
// Set translucent. (Default value is already true, so this can be removed if desired.)
UINavigationBar.appearance().translucent = true

Have you tried setting the navigationBar's alpha property? In your root view controller to the navigation controller...
[self.navigationController.navigationBar setBackgroundColor:[UIColor greenColor]];
[self.navigationController.navigationBar setAlpha:0.3f];

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = UIColor.clear
self.navigationController?.navigationBar.isTranslucent = true
If the above code is not working then set edgesForExtendedLayout to all.
self.edgesForExtendedLayout = .all

Related

iOS 11 navigation bar transparent with large titles

I have default preferences for uinavigationbar:
UINavigationBar.appearance().barTintColor = .red
UINavigationBar.appearance().titleTextAttributes = [ NSAttributedStringKey.foregroundColor:#colorLiteral(red: 1, green: 0.99997437, blue: 0.9999912977, alpha: 1)]
if #available(iOS 11.0, *) {
UINavigationBar.appearance().largeTitleTextAttributes = [ NSAttributedStringKey.foregroundColor:#colorLiteral(red: 1, green: 0.99997437, blue: 0.9999912977, alpha: 1)]
}
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().tintColor = #colorLiteral(red: 1, green: 0.99997437, blue: 0.9999912977, alpha: 1)
Structure: UINaviagtionController -> PostsTableViewController -> PostTableViewController.
I want to have large navigation bar on PostsViewController (with opaque background color) and transparent navigation bar on PostViewController.
In PostTableViewController i add:
self.navigationController?.navigationBar.backgroundColor = UIColor.clear
self.navigationController?.navigationBar.barTintColor = .clear
self.automaticallyAdjustsScrollViewInsets = false
//self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
//self.navigationController?.navigationBar.shadowImage = UIImage()
if #available(iOS 11.0, *) {
print("asd")
self.tableView.insetsContentViewsToSafeArea = false
self.tableView.contentInsetAdjustmentBehavior = .never
} else {
self.automaticallyAdjustsScrollViewInsets = false
}
Navigation bar is BLACK. I dont understand how make it transparent...
UPDATE:
git hub repository: https://github.com/Mazorati/testnavbar
i set isTranslucent = true, but large navigation becomes also transparent. Only default navigation is ok.
But i want navigationbar color to be opaque, so:
self.navigationController?.view.backgroundColor = .red
self.navigationController?.navigationBar.isTranslucent = false
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationItem.largeTitleDisplayMode = .automatic
As the result:
3D layers:
have you tried changing it to translucent?
self.navigationController?.navigationBar.isTranslucent = true
UPDATE:
You must remember that the navigation bar belongs to the UINavigationController which holds the views inside it, so that when you change it in one it changes for all.
The solution would be to change it to translucent in the second view controller's viewWillAppear method and change it to not translucent in the viewDidDissapear method. Play with the viewWill and viewDid appear methods until you find the right one for your needs.
Try this, this make your navigation bar transparent.
let img = UIImage()
navigationController?.navigationBar.shadowImage = img
navigationController?.navigationBar.setBackgroundImage(img, for: .default)

More Tab, Row Image Tint (Xcode 9 + Swift 4)

so I'm using the native "more" function for tab bars in Xcode. I've managed to style the navigation bar & title color programmatically.
//sets the font color
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.white]
//sets the tint color, which dictates the button color
UINavigationBar.appearance().tintColor = UIColor.white
//sets the Bar tint color
UINavigationBar.appearance().barTintColor = UIColor(red: 0/255, green: 175/255, blue: 65/255, alpha: 1.0)
But is there a way to change the tint on these blue icons (reference images below)? The images I'm uploading are green, but it's being tinted & I can't find the setting. Does anyone know how to change this?
Image 1, Image 2
You only need to initialize the image:
UIImage.(withRenderingMode: .alwaysTemplate)
and then change
UIImageView.tintColor = .green

UINavigationItem Transparency iOS

I am using Navigation controller in my app. For my view controller, I used UINavigationItem and added UIBarButton items and title views.
I need to implement transparency to my Navigation Bar.
I have added the below code.
self.navigationController?.navigationBar.isTranslucent = true
let navAlpha = 0.7// Your appropriate calculation
let image = UIImage.imageFromColor(color: UIColor.red.withAlphaComponent(CGFloat(navAlpha)))
self.navigationController?.navigationBar.setBackgroundImage(image, for: UIBarMetrics.default)
self.navigationController?.navigationBar.barStyle = .default
The output of this is:
How do I make whole navigation bar including UINavigationItem transparent?
Add this code in first view Controller.
var navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.isTranslucent = true
let navAlpha = 0.7// Your appropriate calculation
let image = UIImage.imageFromColor(color:
UIColor.red.withAlphaComponent(CGFloat(navAlpha)))
navigationBarAppearace.setBackgroundImage(image, for: UIBarMetrics.default)
navigationBarAppearace.barStyle = .default
I think you could do this in storyboard. Set your Top Bar to be inferred navigation controller. and do this for navigation bar.
Try this
AppDelegate
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().barTintColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
UINavigationBar.appearance().titleTextAttributes = [
NSForegroundColorAttributeName: WHITE_COLOR]
UINavigationBar.appearance().tintColor = WHITE_COLOR
UINavigationBar.appearance().isTranslucent = true
To make the navigation bar completely transparent:
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.backgroundColor = UIColor.clear
I don't understand why did you add red image as the navigation bar's backgroundImage if you want to make it transparent.

Blur effect on navigation bar while using a tableviewcontroller

Real time blur effect for Navigation Bar
Tried the solution mentioned in the above post,
AppDelegate.swift
// Sets background to a blank/empty image
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default)
// Sets shadow (line below the bar) to a blank image
UINavigationBar.appearance().shadowImage = UIImage()
// Sets the translucent background color
UINavigationBar.appearance().backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
// Set translucent. (Default value is already true, so this can be removed if desired.)
UINavigationBar.appearance().translucent = true
RootVC.swift
func addBlurEffect() {
// Add blur view
let bounds = self.navigationController?.navigationBar.bounds as CGRect!
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
visualEffectView.frame = bounds
visualEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
self.navigationController?.navigationBar.addSubview(visualEffectView)
self.navigationController?.navigationBar.sendSubviewToBack(visualEffectView)
// Here you can add visual effects to any UIView control.
// Replace custom view with navigation bar in above code to add effects to custom view.
}
In viewDidLoad used self.addBlurEffect.
Problem, is status bar is still not blurred, and the blur effect is restricted only to RootVC.swift.
How can I extend it to all sub VCs?
Give this a shot:
bounds.offsetInPlace(dx: 0.0, dy: -20.0)
bounds.size.height = bounds.height + 20.0
Found it here

iOS Navbar Appearing Faded

The navbar color appears faded at the top. I'm using a UINavigationController, and the navbar is showing up a lot lighter than it should. Any ideas on how to fix it? Here is my code:
self.navigationController!.navigationBar.hidden = false
self.navigationController!.navigationBar.backgroundColor = UIColor(red: 0.459, green: 0.102, blue: 1, alpha: 1)
let titleDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController!.navigationBar.titleTextAttributes = titleDict as? Dictionary
self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()
Add these lines to your .plist file. Then, set style Black and you problem should be fixed.
1.Do the following change
2.You are setting background color so it is faded but we have to set bartint color
self.navigationController?.navigationBar.barTintColor = UIColor.red
This will set the bartint color to red, you can set any you want

Resources