back button title color not changed while we open popover or present form controller in iOS 13 - swift

In iOS 13 back button title color not dimmed whenever we open popover or present other controller. Other part of application grayed out but not back button.
also tintColorDidChange function is not available for UIBarButtonItem so is there any way to do grayed out all back button titles.
Note: Back button image is being grayed.

Have you try by changing tint color of bar button?
I got same problem and solved by using
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.clear]
self.navigationController?.navigationBar.tintColor = .red // put your desire color
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)

Related

how does instagram's custom navigation bar created?

I'm working on an iOS app and gonna work on the navigation controller part.
The UI of the navigation bar is not complex in my app; basically, it should have an app logo on the left an app name in the middle, and two bar button items on the right.
While I was researching, I saw the Instagram's navigation is sort of similar to what I want to try, especially the "Instagram" logo on the left.
I'm not sure if I can make a navigation bar like an instagram's navbar with a default UI navigation bar, so I guess I need to make a custom navigation bar with .xib file or something? or is it possible to make it with the default navigation bar and some codes??
If you can walk through the approach you take, please let me know...
This can be easily done with a default UINavigationController. For the logo you can create a UIBarButtonItem and set the image to whatever image you want (e.g a logo).
I have a function that sets the collection view's offset to 0 when tapping on the logo similar to Instagram.
For the 3 buttons on the right, you can do something like this:
self.navigationItem.rightBarButtonItems = [button1, button2, button3]
Each button would be their own UIBarButtonItem and then add a selector to each of them.
Here is something similar to what I have in my app:
let calendarButtonItem = UIBarButtonItem(
image: UIImage(
systemName: "calendar.badge"),
style: .done,
target: self,
action: #selector(handleCalendarTap))
let navLogoButtonItem = UIBarButtonItem(
image: UIImage(named: "nav-logo"),
style: .plain,
target: self,
action: #selector(handleNavLogoTap))
self.navigationItem.rightBarButtonItem = calendarButtonItem
self.navigationItem.leftBarButtonItem = logo

How to set navigationBar back button image to default symbols?

there is one screen that i don't want to show back button symbols.
i create a empty image and change the navigation bar back button image.(code like following)
navigationController?.navigationBar.backIndicatorImage = UIImage(named: "mainicon_gray-13")
navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "mainicon_gray-13")
navigationItem.backBarButtonItem = UIBarButtonItem(title: "demo", style: .plain, target: nil, action: nil)
screen like following Picture
But all of backBarButtonItem changed, i need to set backBarButtonItem to default symbols "<" when i back to the view.
Is there any way to set navigation bar back button image to default image?
i want the navigationBar like following picture
following is the way that i found without change back button settings to do same event.
use leftBarButtonItem and set popViewController to go back before screen.
override func viewDidLoad() {
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "test", style: .plain, target: self,action: #selector(backViewBtnFnc))
}
#objc func backViewBtnFnc(){
self.navigationController?.popViewController(animated: true)
}

Left bar button item on NavigationBar not show full text when i present the viewcontroller

Left bar button with image not show full text, when i present that viewcontroller.
i use below code for it
let leftButton: UIBarButtonItem = UIBarButtonItem(image: buttonImg, style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.dismissVC))
leftButton.title = title
navigationItem.leftBarButtonItem = leftButton
And when i use backbarbuttonitem instead of leftBarButtonItem button not displayed.
please give need full suggestion

How do I get back button effect (<)

I am writing an app , where I want custom back effect of the default OS. Like the system which is giving with Settings ( <)
< Icon
Refer this image (I want the effect like Settings with the <)
I already have the functionality, I just want the look and feel.
Effect what I am getting.
I have tried the following
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "cancel")
Also, I have tried adding it via Storyboard. How do I get it ?
Use the backBarButtonItem and you will get right effect.
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Plain, target: self, action: "cancel")
Also, you make sure
self.navigationItem.backBarButtonItem will be shown only after your have pushed another one view to navigation stack, controlled by self.navigationController, if no left button on navigation bar is displayed.

Invoking the real Back Button Icon - Swift

The code below manages the Back button, but obviously puts the word Back up in lieu of the Icon:
self.navigationItem.hidesBackButton = false
let newBackButton = UIBarButtonItem(title: "Back", style: .Plain, target: self, action: "segueBack")
navigationItem.leftBarButtonItem = newBackButton
How do I get iOS the invoke the back button icon? In Cocoa there was a call along the lines of:
[backButton setImage:[UIImage imageNamed:BACK_BUTTON_DEFAULT_ICON] forState:UIControlStateNormal];
You have to create your own button object in order to set its title. You can initWithTitle or create it and then set the title afterward.
The backBarButtonItem only affects its child views that are pushed on top of it in the navigation stack. Depending on your design the root view can't be popped any further and can't have a back button. Though, you can affect the leftBarButtonItem.
Create a UIBarButtonItem instead of setting the title of the existing one.
For example:
let newBackButton = UIBarButtonItem (title: "Back", style: .Plain, target: self, action: "segueBack")
self.navigationItem.backBarButtonItem = newBackButton
Set it on the "parent" view controller, where the Back button will return to.