In my app, I have a Table view with a search view of weight 197 above table cell. There is a button for toggle search on pressing of which the content of table view needs to be offset accordingly. But I am not able to get the needed one. Here is the code snippet.
override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    self.tableShow.reloadData()
    DispatchQueue.main.async {
    self.tableShow.contentOffset = CGPoint(x: 0, y: 0)
}  
@IBAction func toggleSearch(_ sender: Any) {
    UIView.animate(withDuration: 0.5) {
    if(self.searchView.isHidden){
        self.searchView.isHidden = false
    }
    else
    {
        self.searchView.isHidden = true
    }
    if (self.tableShow.contentOffset.y >= 197 ){
        self.tableShow.contentOffset = CGPoint(x: 0, y: 0)
        if !self.noRecordLabel.isHidden {
            self.noRecordLabel.isHidden = true
        }
    } else {
        self.tableShow.contentOffset = CGPoint(x: 0, y: 197                                     
        if self.jobsData.count == 0 {
            self.noRecordLabel.isHidden = false
        }
    }
}
 
     
    