Skip to content

Commit

Permalink
Fixed issue #97: Search bar UI issues under iOS 11 - XCode 9
Browse files Browse the repository at this point in the history
  • Loading branch information
Janglinator committed Oct 15, 2017
1 parent 04bfffa commit 725f66d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions netfox/iOS/NFXListController_iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,32 @@ class NFXListController_iOS: NFXListController, UITableViewDelegate, UITableView
self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage.NFXClose(), style: .plain, target: self, action: #selector(NFXListController_iOS.closeButtonPressed))

self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.NFXSettings(), style: .plain, target: self, action: #selector(NFXListController_iOS.settingsButtonPressed))

let searchView = UIView()
searchView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width - 60, height: 0)
searchView.autoresizingMask = [.flexibleWidth]
searchView.autoresizesSubviews = true
searchView.backgroundColor = UIColor.clear

self.searchController = UISearchController(searchResultsController: nil)
self.searchController.searchResultsUpdater = self
self.searchController.delegate = self
self.searchController.hidesNavigationBarDuringPresentation = false
self.searchController.dimsBackgroundDuringPresentation = false
searchView.addSubview(self.searchController.searchBar)
self.searchController.searchBar.autoresizingMask = [.flexibleWidth]
self.searchController.searchBar.sizeToFit()
self.searchController.searchBar.backgroundColor = UIColor.clear
self.searchController.searchBar.barTintColor = UIColor.white
self.searchController.searchBar.searchBarStyle = .minimal
searchView.frame = self.searchController.searchBar.frame
self.searchController.view.backgroundColor = UIColor.clear

self.navigationItem.titleView = searchView
if #available(iOS 11.0, *) {
self.navigationItem.searchController = self.searchController
} else {
let searchView = UIView()
searchView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width - 60, height: 0)
searchView.autoresizingMask = [.flexibleWidth]
searchView.autoresizesSubviews = true
searchView.backgroundColor = UIColor.clear
searchView.addSubview(self.searchController.searchBar)
self.searchController.searchBar.sizeToFit()
searchView.frame = self.searchController.searchBar.frame

self.navigationItem.titleView = searchView
}

NotificationCenter.default.addObserver(
self,
Expand Down

0 comments on commit 725f66d

Please sign in to comment.