Change the alpha value of the navigation bar item in iOS Swift
You're setting the alpha of the entire bar to 0.15. You should be setting only the barTintColor
attribute of it to a color with an alpha of 0.15 like so:
self.navigationController?.navigationBar.barTintColor = UIColor.yourColorGoesHere().colorWithAlphaComponent(0.15)
Changing alpha value of navigationbar so underlying objects are visible
]you can access navigationBackgroundView
self.navigationController?.navigationBar.isTranslucent = true
let navigationBackgroundView = self.navigationController?.navigationBar.subviews.first
navigationBackgroundView?.alpha = 0.3
Setting a background color with alpha in Navigation bar
If you just want the NavigationBar
(excluding status bar) background with alpha.. Try this
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.backgroundColor = UIColor.blue.withAlphaComponent(0.5)
}
If you want background color with alpha including status bar
, Im afraid you have to use an image with alpha value. see this
Edit the alpha of navigation bar when scrolls tableview
It's probably too late, but for future reference, you could do something like this:
func scrollViewDidScroll(scrollView: UIScrollView) {
self.navigationController!.navigationBar.alpha = 1 - (self.tableView.contentOffset.y / (self.tableView.contentSize.height - self.tableView.frame.size.height));
}
On this delegate you have the values of contentOffset of scrollview or tableView, and you can observe the value of this property to make the behavior you desire.
Hope it helps!
Default Alpha value of navigation bar in Lollipop
I've made some test with navigation bar and found that alpha of navBar when android:windowTranslucentNavigation = true
is 40% of black color.
So color in hex would be: #66000000
Here is steps how I calculated this value:
- I made screenshot as presented below
- Then I open it in Gimp image editor and take RGB values of each color
- White is (255,255,255), white under navBar (153,153,153)
- Grey is (150,150,150), grey under navBar (90,90,90)
Then I calculate as next:
255 is 100%
153 is x
x = 153 * 100 / 255 = 60%
So I calculated invert value of alpha channel, the true value of alpha channel is 100 - 60 = 40%
ARGB value of 40% is (102,0,0,0)
in hex it's #66000000
Related Topics
Multiple Checkmark When Row Selected in Uitableview iOS
Scanning Barcode or Qr Code in Swift 3.0 Using Avfoundation
iPad iOS7 - Uiimagepickercontroller in Uipopovercontroller Has Wrong Preview Image
Swiftui Transitions: Scale from Some Frame - Like iOS Homescreen Is Doing When Opening an App
"This App Is Not Allowed to Query for Scheme Cydia" iOS9 Error
Is It Just the iPhone Simulator That Is Restricted to Intel Only MAC'S
Xcode 8 Swift 3 Uitableview Space Between Cells
View Controller Responds to App Delegate Notifications in iOS 12 But Not in iOS 13
Info.Plist File for React Native iOS App Using Expo Sdk
Change the Alpha Value of the Navigation Bar
iOS 10 Rich Media Push Notification (Media Attachment) in Objective-C
Are There Any Analogues of [Nsstring Stringwithformat:] for Nsattributedstring
Swift - Pushviewcontroller from Appdelegate, Rootviewcontroller.Navigationcontroller Is Nil
iPhone Opengl Es 2.0 - Pixel Perfect Textures
Uilabel: Background Dependent Color