I am trying to keep a UIView with a label, segmentedControl and a button at the top of my UITableViewController as it scrolls. I cannot use a ViewController with UITableView because my TableViewCells are static with UITextFields in them. I know this can be done via ViewController and ContainerViewController, however, this makes things complicated with the amount of data that needs to get passed between the views. I am looking for a scrollViewDidScroll solution in swift.
Here is what I have so far. I have the View already created in storyboards (maybe that is part of the problem.) labelView is connected via outlet.
override func scrollViewDidScroll(scrollView: UIScrollView) {
var rect = self.labelView.frame
rect.origin.y = min(0,scrollView.contentOffset.y + scrollView.contentInset.top);
self.labelView.frame = rect;
}