Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Magnetic circular dichroism imaging of atomic-scale antiferromagnetic order at a buried interface

    March 24, 2026

    Telenor IoT expands global connectivity with launch of Global APN

    March 24, 2026

    swiftui – How to show/hide iOS toolbar buttons with fancy Liquid Glass animation?

    March 24, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»swiftui – How to show/hide iOS toolbar buttons with fancy Liquid Glass animation?
    iOS Development

    swiftui – How to show/hide iOS toolbar buttons with fancy Liquid Glass animation?

    big tee tech hubBy big tee tech hubMarch 24, 2026003 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    swiftui – How to show/hide iOS toolbar buttons with fancy Liquid Glass animation?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    When the button is shown as a toolbar item, the transition and associated animation is controlled by the native toolbar and I don’t think there is much you can do to change the animation effect.

    • The transition seems to be a blur effect.
    • It is important to include an .animation modifier, otherwise there is no animation at all. However, changing the animation style to something like .bouncy has no effect – it seems that the style of animation is controlled by the native toolbar.

    Here is a standalone example to show the native animation effect (this is just an elaborated version of what you showed in the question):

    struct ContentView: View {
        @State private var text = ""
        var body: some View {
            NavigationStack {
                VStack {
                    TextField("Text", text: $text)
                        .textFieldStyle(.roundedBorder)
                        .toolbarVisibility(.visible, for: .automatic)
                        .padding()
                    Spacer()
                }
                .toolbar {
                    if !text.isEmpty {
                        ToolbarItem(placement: .topBarTrailing) {
                            Button("Delete", systemImage: "trash", role: .destructive) {
                                text = ""
                            }
                        }
                    }
                }
                .animation(.default, value: text.isEmpty)
                .toolbarVisibility(.visible, for: .automatic)
            }
        }
    }
    

    Animation


    The native animation can be made a bit more interesting if a ToolbarItemGroup is used, together with a second state variable that is used to change what is shown inside the group:

    • the group is only shown when the text is not empty
    • the group shows a Spacer when first shown, then the spacer is replaced by the button
    • the switch can be performed using .task and withAnimation.
    @State private var isButtonShowing = false
    
    VStack {
        // ... as before
    }
    .toolbar {
        if !text.isEmpty {
            ToolbarItemGroup(placement: .topBarTrailing) {
                if isButtonShowing {
                    Button("Delete", systemImage: "trash", role: .destructive) {
                        text = ""
                    }
                } else {
                    Spacer()
                }
            }
        }
    }
    .animation(.default, value: text.isEmpty)
    .toolbarVisibility(.visible, for: .automatic)
    .task(id: text.isEmpty) {
        withAnimation {
            isButtonShowing = !text.isEmpty
        }
    }
    

    Animation

    The difference is not huge, but the animation now has a bit of a bounce to it.


    An alternative way to show the button would be to use either .safeAreaBar or .overlay, instead of as a toolbar item. This way, you get much more control over the style of transition and animation.

    In order to make sure the button looks the same as a toolbar button, I would suggest using a custom ButtonStyle. For example:

    struct RoundGlassButton: ButtonStyle {
        func makeBody(configuration: Configuration) -> some View {
            configuration.label
                .font(.title2)
                .labelStyle(.iconOnly)
                .frame(minWidth: 44, minHeight: 44)
                .contentShape(.circle)
                .glassEffect(.regular.interactive(), in: .circle)
        }
    }
    

    This is how the button with custom style can then be shown with a bouncy animation:

    struct ContentView: View {
        @State private var text = ""
        var body: some View {
            NavigationStack {
                VStack {
                    TextField("Text", text: $text)
                        .textFieldStyle(.roundedBorder)
                        .toolbarVisibility(.visible, for: .automatic)
                        .padding()
                    Spacer()
                }
            }
            .safeAreaBar(edge: .top, alignment: .trailing) {
                if !text.isEmpty {
                    Button("Delete", systemImage: "trash", role: .destructive) {
                        text = ""
                    }
                    .buttonStyle(RoundGlassButton())
                    .padding(.horizontal, 16)
                    .transition(.asymmetric(
                        insertion: .scale.animation(.bouncy(duration: 0.3, extraBounce: 0.25)),
                        removal: .scale.combined(with: .opacity).animation(.easeInOut(duration: 0.3))
                    ))
                }
            }
        }
    }
    

    Animation



    Source link

    Animation buttons fancy Glass iOS Liquid showhide SwiftUI Toolbar
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – Unwanted Communication Reporting Extension deletes messages always

    March 23, 2026

    javascript – Client-side video crop + audio mux on iOS Safari with HEVC — any viable approach?

    March 22, 2026

    Flutter In-App Purchase: How to handle callbacks and pricing for iOS Offer Code Redemption Sheets?

    March 21, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Magnetic circular dichroism imaging of atomic-scale antiferromagnetic order at a buried interface

    March 24, 2026

    Telenor IoT expands global connectivity with launch of Global APN

    March 24, 2026

    swiftui – How to show/hide iOS toolbar buttons with fancy Liquid Glass animation?

    March 24, 2026

    A quick guide to recovering a hacked account

    March 24, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Magnetic circular dichroism imaging of atomic-scale antiferromagnetic order at a buried interface

    March 24, 2026

    Telenor IoT expands global connectivity with launch of Global APN

    March 24, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.