Bartek
Bartek

Reputation: 131

Xcode search Controller - show search bar at the start (Swift 4)

I want to show the search engine when loading the controller.

I do not mean:

navigationItem.hidesSearchBarWhenScrolling = false

I want to hide the search engine while scrolling. I only want to show it once at the start, how can I do this?

enter image description here

Upvotes: 0

Views: 334

Answers (1)

Dima
Dima

Reputation: 61

I do this:

            navigationItem.hidesSearchBarWhenScrolling = false

            performTaskAfterDealy(1, {
                self.navigationItem.hidesSearchBarWhenScrolling = true
            })

Work for me :)

ps:

func performTaskAfterDealy(_ timeInteval: TimeInterval, _ task:@escaping () -> ()) {
        DispatchQueue.main.asyncAfter(deadline: (.now() + timeInteval)) {
            task()
        }
    }

Upvotes: 1

Related Questions