Reputation: 71
I have a search bar in the tableview header. I want to offset the position of the search bar that it looks hidden under the nav bar until the user pulls down on the tableview to reveal a search bar. I have looked everywhere to find this but cannot. Can someone please point me in the right direction and or show me how do create this effect in iOS 9 and objective-c. Thank you
Upvotes: 1
Views: 2055
Reputation: 599
Swift 3:
let point = CGPoint(x: 0, y:(self.navigationController?.navigationBar.frame.size.height)!)
self.tableView.setContentOffset(point, animated: true)
This is for regular navigation bar. For search controller:
Replace navigationController
and navigationBar
with karthik's y coordinate.
Upvotes: 0
Reputation: 631
// search is hidden in TableView by default
For swift
self.TableView.setContentOffset(CGPointMake(0,self.searchController.searchBar.frame.size.height), animated: false)
For Objective c
[[self staffTableView] setContentOffset:[CGPointMake(0, frameHeight)] animated:YES];
When you pullDown it will reveal you searchbar
(added in the headerview)
Hope this will help you to solve your problem. it was working for me.
Upvotes: 4