Use iOS 11 design language

This commit is contained in:
Bob Sun 2017-10-07 00:24:30 -07:00
parent d5353ba4d1
commit c57ae4f88e
2 changed files with 30 additions and 12 deletions

View file

@ -776,8 +776,8 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="ZmJ-0Z-N04" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Settings" image="Settings" selectedImage="Settings" id="6Xa-be-Z8g"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="wWs-15-HDi">
<rect key="frame" x="0.0" y="20" width="414" height="44"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" largeTitles="YES" id="wWs-15-HDi">
<rect key="frame" x="0.0" y="20" width="414" height="96"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>

View file

@ -39,7 +39,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
uiSearchController.searchResultsUpdater = self
uiSearchController.dimsBackgroundDuringPresentation = false
uiSearchController.searchBar.isTranslucent = false
uiSearchController.searchBar.backgroundColor = UIColor.gray
uiSearchController.searchBar.sizeToFit()
return uiSearchController
}()
@ -48,10 +47,13 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
syncControl.addTarget(self, action: #selector(handleRefresh(_:)), for: UIControlEvents.valueChanged)
return syncControl
}()
private lazy var searchBarView: UIView = {
let uiView = UIView(frame: CGRect(x: 0, y: 64, width: self.view.bounds.width, height: 56))
uiView.addSubview(self.searchController.searchBar)
return uiView
private lazy var searchBarView: UIView? = {
guard #available(iOS 11, *) else {
let uiView = UIView(frame: CGRect(x: 0, y: 64, width: self.view.bounds.width, height: 56))
uiView.addSubview(self.searchController.searchBar)
return uiView
}
return nil
}()
private lazy var backUIBarButtonItem: UIBarButtonItem = {
let backUIBarButtonItem = UIBarButtonItem(title: "Back", style: .plain, target: self, action: #selector(self.backAction(_:)))
@ -188,18 +190,28 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
} else {
searchController.searchBar.scopeButtonTitles = nil
}
if #available(iOS 11.0, *) {
navigationItem.hidesSearchBarWhenScrolling = true
}
}
override func viewDidLoad() {
super.viewDidLoad()
tabBarController!.delegate = self
searchController.searchBar.delegate = self
tableView.delegate = self
tableView.dataSource = self
tableView.contentInset = UIEdgeInsetsMake(56, 0, 0, 0)
definesPresentationContext = true
view.addSubview(searchBarView)
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .automatic
navigationItem.hidesSearchBarWhenScrolling = true
} else {
// Fallback on earlier versions
tableView.contentInset = UIEdgeInsetsMake(56, 0, 0, 0)
view.addSubview(searchBarView!)
}
tableView.refreshControl = syncControl
SVProgressHUD.setDefaultMaskType(.black)
tableView.register(UINib(nibName: "PasswordWithFolderTableViewCell", bundle: nil), forCellReuseIdentifier: "passwordWithFolderTableViewCell")
@ -219,12 +231,18 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
if let path = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: path, animated: false)
}
if #available(iOS 11.0, *) {
navigationItem.hidesSearchBarWhenScrolling = false
}
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
searchBarView.frame = CGRect(x: 0, y: navigationController!.navigationBar.bounds.size.height + UIApplication.shared.statusBarFrame.height, width: UIScreen.main.bounds.width, height: 56)
searchController.searchBar.sizeToFit()
guard #available(iOS 11, *) else {
searchBarView?.frame = CGRect(x: 0, y: navigationController!.navigationBar.bounds.size.height + UIApplication.shared.statusBarFrame.height, width: UIScreen.main.bounds.width, height: 56)
searchController.searchBar.sizeToFit()
return
}
}
func numberOfSections(in tableView: UITableView) -> Int {