diff --git a/Session/Home/GlobalSearch/GlobalSearchViewController.swift b/Session/Home/GlobalSearch/GlobalSearchViewController.swift index c88b527be..ebbb24927 100644 --- a/Session/Home/GlobalSearch/GlobalSearchViewController.swift +++ b/Session/Home/GlobalSearch/GlobalSearchViewController.swift @@ -55,6 +55,8 @@ class GlobalSearchViewController: BaseVC, UITableViewDelegate, UITableViewDataSo result.showsCancelButton = true return result }() + + private var searchBarWidth: NSLayoutConstraint? internal lazy var tableView: UITableView = { let result: UITableView = UITableView(frame: .zero, style: .grouped) @@ -97,6 +99,11 @@ class GlobalSearchViewController: BaseVC, UITableViewDelegate, UITableViewDataSo super.viewWillDisappear(animated) searchBar.resignFirstResponder() } + + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + searchBarWidth?.constant = size.width - 32 + } private func setupNavigationBar() { // This is a workaround for a UI issue that the navigation bar can be a bit higher if @@ -107,7 +114,7 @@ class GlobalSearchViewController: BaseVC, UITableViewDelegate, UITableViewDataSo searchBar.sizeToFit() searchBar.layoutMargins = UIEdgeInsets.zero searchBarContainer.set(.height, to: 44) - searchBarContainer.set(.width, to: UIScreen.main.bounds.width - 32) + searchBarWidth = searchBarContainer.set(.width, to: UIScreen.main.bounds.width - 32) searchBarContainer.addSubview(searchBar) navigationItem.titleView = searchBarContainer