     
     func willPresentSearchController(_ searchController: UISearchController) {
         searchController.searchBar.textField?.textColor = .white
+        UIView.animate(withDuration: 0.2) {
+            searchController.searchBar.showsCancelButton = true
+        }
     }
     
     func willDismissSearchController(_ searchController: UISearchController) {
         realmView.tableView.reloadData()
-    }
-}
+        UIView.animate(withDuration: 0.2) {
+            searchController.searchBar.showsCancelButton = false
+        }
+    }
+}

        }
    }
    
    private func searchForText(_ searchText:String?) {
        if let searchText = searchText {
            if searchText.isNonEmpty {
                filteredObjects = objects.filter({ isIncluded(for: searchText, concerning: $0) })

            searchController.dimsBackgroundDuringPresentation = false
            searchController.searchBar.sizeToFit()
            searchController.searchBar.tintColor = .white
            if #available(iOS 11.0, *) {
                navigationItem.searchController = searchController
            } else {
