S
S
Stanislav Korolevskiy2017-07-15 12:53:29
Swift
Stanislav Korolevskiy, 2017-07-15 12:53:29

How to fix searchBar under navigationBar?

Hello! searchBar scrolls along with tableView. How to fix searchBar under navigationBar?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AzamatBolegenov, 2017-07-18
@AzamatBolegenov

You most likely have it inside the TableView. Gotta get him out of there
f1ebfcfaf9684c1994a271877edcfeb6.png

A
Anton Gorb, 2017-07-19
@AntonGorb

Add searchBar as subview navigationBar

.
    navigationController?.navigationBar.isTranslucent = false
    navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
    navigationController?.navigationBar.barStyle = .black
    navigationController?.navigationBar.barTintColor = UIColor.red
    navigationController?.navigationBar.shadowImage = UIImage()
    title = "User profile";

    let searchBar = UISearchBar()
    searchBar.placeholder = "Search"
    searchBar.frame = CGRect(x: 0, y: 0, width: (navigationController?.view.bounds.size.width)!, height: 64)
    searchBar.barStyle = .default
    searchBar.isTranslucent = false
    searchBar.barTintColor = UIColor.red
    searchBar.backgroundImage = UIImage()
    view.addSubview(searchBar)

A
Agranatmark, 2017-07-15
@Agranatmark

Take it out of the table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question