Created
November 17, 2025 15:01
-
-
Save shivaduke28/6b78bb9322ee64e5fa50cdac587cdc2e to your computer and use it in GitHub Desktop.
Make TabView background color transparent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct TransparentTabItem: UIViewRepresentable { | |
| func makeUIView(context: Context) -> UIView { | |
| let view = UIView(frame: .zero) | |
| DispatchQueue.main.async { | |
| var count = 0 | |
| var currentParent = view.superview | |
| while let parent = currentParent, count < 2 { | |
| if parent.backgroundColor != nil{ | |
| parent.backgroundColor = UIColor.clear | |
| count += 1 | |
| } | |
| currentParent = parent.superview | |
| } | |
| } | |
| return view | |
| } | |
| func updateUIView(_ uiView: UIView, context: Context) {} | |
| } | |
| extension View { | |
| public func transparentTabItem<V>(@ViewBuilder _ label: () -> V) -> some View where V : View { | |
| ZStack { | |
| TransparentTabItem() | |
| self | |
| }.tabItem(label) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment