Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xcuserdata
43 changes: 23 additions & 20 deletions SearchTextField/Classes/SearchTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,28 +205,30 @@ open class SearchTextField: UITextField {

// Create the filter table and shadow view
fileprivate func buildSearchTableView() {
if let tableView = tableView, let shadowView = shadowView {
tableView.layer.masksToBounds = true
tableView.layer.borderWidth = theme.borderWidth > 0 ? theme.borderWidth : 0.5
tableView.dataSource = self
tableView.delegate = self
tableView.separatorInset = UIEdgeInsets.zero
tableView.tableHeaderView = resultsListHeader
if forceRightToLeft {
tableView.semanticContentAttribute = .forceRightToLeft
}

shadowView.backgroundColor = UIColor.lightText
shadowView.layer.shadowColor = UIColor.black.cgColor
shadowView.layer.shadowOffset = CGSize.zero
shadowView.layer.shadowOpacity = 1

self.window?.addSubview(tableView)
} else {
tableView = UITableView(frame: CGRect.zero)
shadowView = UIView(frame: CGRect.zero)
guard let tableView = tableView, let shadowView = shadowView else {
self.tableView = UITableView(frame: CGRect.zero)
self.shadowView = UIView(frame: CGRect.zero)
buildSearchTableView()
return
}

tableView.layer.masksToBounds = true
tableView.layer.borderWidth = theme.borderWidth > 0 ? theme.borderWidth : 0.5
tableView.dataSource = self
tableView.delegate = self
tableView.separatorInset = UIEdgeInsets.zero
tableView.tableHeaderView = resultsListHeader
if forceRightToLeft {
tableView.semanticContentAttribute = .forceRightToLeft
}

shadowView.backgroundColor = UIColor.lightText
shadowView.layer.shadowColor = UIColor.black.cgColor
shadowView.layer.shadowOffset = CGSize.zero
shadowView.layer.shadowOpacity = 1

self.window?.addSubview(tableView)

redrawSearchTableView()
}

Expand Down Expand Up @@ -299,6 +301,7 @@ open class SearchTextField: UITextField {
tableViewFrame.origin = self.convert(tableViewFrame.origin, to: nil)
tableViewFrame.origin.x += 2 + tableXOffset
tableViewFrame.origin.y += frame.size.height + 2 + tableYOffset
self.tableView?.frame.origin = tableViewFrame.origin // Avoid animating from (0, 0) when displaying at launch
UIView.animate(withDuration: 0.2, animations: { [weak self] in
self?.tableView?.frame = tableViewFrame
})
Expand Down