Skip to content

Instantly share code, notes, and snippets.

@shivaduke28
Created November 17, 2025 15:01
Show Gist options
  • Select an option

  • Save shivaduke28/6b78bb9322ee64e5fa50cdac587cdc2e to your computer and use it in GitHub Desktop.

Select an option

Save shivaduke28/6b78bb9322ee64e5fa50cdac587cdc2e to your computer and use it in GitHub Desktop.
Make TabView background color transparent
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