From 2c14073b04fb28185cb96c5eba51dae3b7f2842b Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Thu, 29 Sep 2022 17:00:23 +1000 Subject: [PATCH] fix global search search bar width --- .../Home/GlobalSearch/GlobalSearchViewController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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