mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			37 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			37 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Swift
		
	
| 
											5 years ago
										 | import UIKit | ||
| 
											6 years ago
										 | 
 | ||
| 
											5 years ago
										 | public final class SearchBar : UISearchBar { | ||
| 
											6 years ago
										 |      | ||
| 
											5 years ago
										 |     public override init(frame: CGRect) { | ||
| 
											6 years ago
										 |         super.init(frame: frame) | ||
| 
											6 years ago
										 |         setUpStyle() | ||
| 
											6 years ago
										 |     } | ||
|  |      | ||
| 
											5 years ago
										 |     public required init?(coder: NSCoder) { | ||
| 
											6 years ago
										 |         super.init(coder: coder) | ||
| 
											6 years ago
										 |         setUpStyle() | ||
| 
											6 years ago
										 |     } | ||
|  |      | ||
| 
											6 years ago
										 |     private func setUpStyle() { | ||
| 
											6 years ago
										 |         searchBarStyle = .minimal // Hide the border around the search bar | ||
|  |         barStyle = .black // Use Apple's black design as a base | ||
|  |         tintColor = Colors.accent // The cursor color | ||
| 
											5 years ago
										 |         let searchImage = #imageLiteral(resourceName: "searchbar_search").withTint(Colors.searchBarPlaceholder)! | ||
| 
											6 years ago
										 |         setImage(searchImage, for: .search, state: .normal) | ||
| 
											5 years ago
										 |         let clearImage = #imageLiteral(resourceName: "searchbar_clear").withTint(Colors.searchBarPlaceholder)! | ||
| 
											6 years ago
										 |         setImage(clearImage, for: .clear, state: .normal) | ||
| 
											6 years ago
										 |         let searchTextField: UITextField | ||
|  |         if #available(iOS 13, *) { | ||
|  |             searchTextField = self.searchTextField | ||
|  |         } else { | ||
|  |             searchTextField = self.value(forKey: "_searchField") as! UITextField | ||
|  |         } | ||
| 
											6 years ago
										 |         searchTextField.backgroundColor = Colors.searchBarBackground // The search bar background color | ||
|  |         searchTextField.textColor = Colors.text | ||
|  |         searchTextField.attributedPlaceholder = NSAttributedString(string: NSLocalizedString("Search", comment: ""), attributes: [ .foregroundColor : Colors.searchBarPlaceholder ]) | ||
|  |         setPositionAdjustment(UIOffset(horizontal: 4, vertical: 0), for: UISearchBar.Icon.search) | ||
|  |         searchTextPositionAdjustment = UIOffset(horizontal: 2, vertical: 0) | ||
|  |         setPositionAdjustment(UIOffset(horizontal: -4, vertical: 0), for: UISearchBar.Icon.clear) | ||
|  |     } | ||
|  | } |