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

    The death of reactive IT: How predictive engineering will redefine cloud performance in 10 years

    February 11, 2026

    Oceanhorn 3: Legend of the Shadow Sea launches March 5 on Apple Arcade

    February 11, 2026

    The danger of glamourizing one shots

    February 11, 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»ios – When removing a ToolbarItem from the navigation bar, how do I make the remaining ToolbarItems resize correctly?
    iOS Development

    ios – When removing a ToolbarItem from the navigation bar, how do I make the remaining ToolbarItems resize correctly?

    big tee tech hubBy big tee tech hubAugust 1, 2025002 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – When removing a ToolbarItem from the navigation bar, how do I make the remaining ToolbarItems resize correctly?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    Because .searchable does not allow for customizing buttons in the search bar, I’ve manually had to recreate the search bar as shown below. However, when removing one of the items in the search bar, the TextField does not resize correctly and effectively inserts padding on the leading edge. When the TextField is focused, it resizes and fills the entire space. If the “Compose” button was already hidden when the search bar is presented, it lays out correctly. How do I resize the TextField after removing the “Compose” button automatically?

    Thanks,
    jjp

    struct ContentView: View {
        @State var isSearchBarVisible = false
        @State var isComposingMessage = false
        @State var searchText = ""
    
        let items: [String] = ["hey", "there", "how", "are", "you"]
    
        var searchItems: [String] {
            items.filter { item in
                item.lowercased().contains(searchText.lowercased())
            }
        }
    
        var body: some View {
            NavigationStack {
                VStack {
                    List {
                        if !searchText.isEmpty {
                            ForEach(searchItems, id: \.self) { item in
                                Text(item)
                            }
                        } else {
                            ForEach(items, id: \.self) { item in
                                Text(item)
                            }
                        }
                    }
                }
                .toolbar {
                    if isSearchBarVisible {
                        ToolbarItem(placement: .principal) {
                            TextField("Search", text: $searchText)
                                .padding(8)
                                .background(Color.gray.opacity(0.2))
                        }
                        ToolbarItem(placement: .topBarTrailing) {
                            Button(action: {
                                isSearchBarVisible = false
                            },[![enter image description here][1]][1]
                                   label: {
                                Text("Cancel")
                            })
                        }
                        if !isComposingMessage {
                            ToolbarItem(placement: .topBarTrailing) {
                                Button(action: {
                                    isComposingMessage.toggle()
                                },
                                       label: {
                                    Text("Compose")
                                })
                            }
                        }
                    }
                    else {
                        ToolbarItem(placement: .topBarLeading) {
                            Button(action: {
                                isSearchBarVisible = true
                            },
                                   label: {
                                Text("Search")
                            })
                        }
                        ToolbarItem(placement: .principal) {
                            Text("Title")
                        }
                        ToolbarItem(placement: .topBarTrailing) {
                            Button(action: {
                                isComposingMessage.toggle()
                            },
                                   label: {
                                Text("Compose")
                            })
                        }
                    }
                }
            }
        }
    }
    
    

    images

    image2

    image3

    image4



    Source link

    bar correctly iOS Navigation remaining removing resize ToolbarItem ToolbarItems
    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 26, using Swift, how can I group multiple Liquid Glass buttons into a single pill view?

    February 11, 2026

    The importance of human touch in AI-driven development – Donny Wals

    February 10, 2026

    ios – Get notification history paginationToken and startTime inconsistency

    February 9, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    The death of reactive IT: How predictive engineering will redefine cloud performance in 10 years

    February 11, 2026

    Oceanhorn 3: Legend of the Shadow Sea launches March 5 on Apple Arcade

    February 11, 2026

    The danger of glamourizing one shots

    February 11, 2026

    Research plots pathway to sustainable solar scale-up

    February 11, 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!

    The death of reactive IT: How predictive engineering will redefine cloud performance in 10 years

    February 11, 2026

    Oceanhorn 3: Legend of the Shadow Sea launches March 5 on Apple Arcade

    February 11, 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.