Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIBarButtonItem with customView doesn't work with usesLargeTitle #503

Open
jpanchal opened this issue Mar 31, 2021 · 4 comments
Open

UIBarButtonItem with customView doesn't work with usesLargeTitle #503

jpanchal opened this issue Mar 31, 2021 · 4 comments

Comments

@jpanchal
Copy link

jpanchal commented Mar 31, 2021

I am trying to use customView for rightNavigationItem along with "usesLargeTitle"

viewController.navigationItem.usesLargeTitle = true
var btn: UIBarButtonItem {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "Alert"), for: .normal)
button.frame = CGRect(x: 0, y: 0, 20, height: 20)
button.addTarget(self, action: #selector(handler), for: .touchUpInside)
return UIBarButtonItem(customView: button)
}
viewController.navigationItem.rightBarButtonItems = [btn]

So when this property is set, it hides the customView behind other blocked views. Any button set inside customView does not show in view stack.

Any suggestions?

@jpanchal jpanchal changed the title UIBarButtonItem with customView doesn't work with userLargeTitle UIBarButtonItem with customView doesn't work with usesLargeTitle Mar 31, 2021
@harrieshin
Copy link
Contributor

Hi @jpanchal, I think you are hiring a limitation on the current largeTitle view which it tried to make it easier for clients to utilize UIBarButtonItem of the UINavigationBar but because we are redrawing/positioning barButtonStack by recreating button but there isn't a way to copy the customView of the barButtonItem to show in 2 different places. What's the scenario that you need to custom button here? You could try to create an new api in NavigationBar.swift to directly add your custom view in rightBarButtonItemsStackView.

@jpanchal
Copy link
Author

jpanchal commented Apr 7, 2021

Hi @harrieshin, thanks for the response. I have an alert icon in rightBarButton and I need to show a badge on top corner on this icon. In order to do that, I need to get access to this view inside rightBarButtonItems. How do I get access to the UIView which is copied inside rightBarButtonItemsStackView?

@harrieshin
Copy link
Contributor

You would need to write code to expose that and handle marshaling between barbuttonitem and customview that client directly inserted.

@jpanchal
Copy link
Author

@harrieshin is it possible currently without updating the SDK source code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants