fluentui-apple icon indicating copy to clipboard operation
fluentui-apple copied to clipboard

UIBarButtonItem with customView doesn't work with usesLargeTitle

Open jpanchal opened this issue 4 years ago • 4 comments

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 avatar Mar 31 '21 21:03 jpanchal

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.

harrieshin avatar Apr 07 '21 04:04 harrieshin

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?

jpanchal avatar Apr 07 '21 15:04 jpanchal

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

harrieshin avatar Apr 16 '21 01:04 harrieshin

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

jpanchal avatar Apr 16 '21 05:04 jpanchal