Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable glass effect on UIBarButtonItem's customView

Currently I am working on making my app ready for iOS 26, and noticed an issue with a UIBarButtonItem(customView:) as a leftBarButtonItem. I want to disable the glass effect.

The glass effect needs to be disabled because UIBarButtonItem has no interaction (attached to it). The customView is just a simple UIImageView containing a logo. What is the best way to go about this?

I already watched the Build a UIKit app with the new design, and Build an AppKit app with the new design. Were the latter hints about the NSToolbarItem.isBordered. Which is exactly what I am looking for, but then the equal in UIKit.

Edit: I am aware of the UIDesignRequiresCompatibility plist key. I am talking about making it work in iOS 26 with glass design.

like image 965
Sem Avatar asked Mar 21 '26 21:03

Sem


1 Answers

If you're still looking for an answer, I think I have a solution for this assuming you had the same problem as me:

SwiftUI

Set .sharedBackgroundVisibility(.hidden) on the ToolbarItem

UIKit

Set .hidesSharedBackground = true on the UIBarButtonItem

Example

//
// SwiftUI
ToolbarItem(placement: .primaryAction) {
  Button {
    ...
  } label: {
    ...
  }
}
.sharedBackgroundVisibility(.hidden) // 👈 here

//
// UIKit

navigationItem.rightBarButtonItem = UserHubBarButtonItem(user: user)
if #available(iOS 26.0, *) {
  navigationItem.rightBarButtonItem?.hidesSharedBackground = true // 👈 here
}
like image 56
jackchmbrln Avatar answered Mar 24 '26 12:03

jackchmbrln



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!