SHARE
TWEET

Untitled

a guest Jun 25th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. override init(frame: CGRect) {
  2.         super.init(frame: frame)
  3.         shared()
  4.         commonInit()
  5.         if let superview = superview {
  6.             setupAutocompleteTable(superview)
  7.         }
  8.     }
  9.  
  10.     public override func willMove(toSuperview newSuperview: UIView?) {
  11.         super.willMove(toSuperview: newSuperview)
  12.         commonInit()
  13.         setupAutocompleteTable(newSuperview!)
  14.  
  15.     }
  16.     lazy var tableView: UITableView = {
  17.         let tableView = UITableView()
  18.         tableView.translatesAutoresizingMaskIntoConstraints = false
  19.         tableView.dataSource = self
  20.         tableView.delegate = self
  21.         tableView.rowHeight = autoCompleteCellHeight
  22.         tableView.isHidden = hidesWhenEmpty ?? true
  23.         tableView.layer.borderColor = UIColor.lightGray.cgColor
  24.         tableView.layer.borderWidth = 0.5
  25.         tableView.layer.zPosition = CGFloat(Float.greatestFiniteMagnitude)
  26.         return tableView
  27.     }()
  28.  
  29.     fileprivate func setupAutocompleteTable(_ view: UIView) {
  30.  
  31.         autoCompleteTableMargin = 10.0
  32.  
  33.         view.addSubview(tableView)
  34.         tableView.topAnchor.constraint(equalTo: view.bottomAnchor, constant: 20).isActive = true
  35.         tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
  36.         tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
  37.         tableView.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: 0).isActive = true
  38.         tableView.heightAnchor.constraint(equalToConstant: 30).isActive = true
  39.  
  40.         autoCompleteTableView = tableView
  41.         autoCompleteTableHeight = 200.0
  42.     }
  43.      
  44. lazy var searchField: GooglePlaceSearchField = {
  45.         let field = GooglePlaceSearchField()
  46.         field.translatesAutoresizingMaskIntoConstraints = true
  47.         field.placeholder = "Enter area, city .."
  48.         field.setIcon(#imageLiteral(resourceName: "zamasearch"))
  49.         field.highLightTypeTextedEnabled = true
  50.         return field
  51.     }()
  52.  
  53.     view.addSubview(searchBgView)
  54.     searchBgView.addSubview(searchField)
  55.      
  56. searchBgView.anchor(top: view.safeAreaLayoutGuide.topAnchor, left: view.leftAnchor, bottom: nil, right: view.rightAnchor, paddingTop: 14, paddingLeft: 20, paddingBottom: 0, paddingRight: 20, width: 0, height: 50, enableInsets: false)
  57.         searchField.anchor(top: searchBgView.topAnchor, left: searchBgView.leftAnchor, bottom: searchBgView.bottomAnchor, right: iconContainerView.leftAnchor, paddingTop: 00, paddingLeft: 20, paddingBottom: 0, paddingRight: 0, width: 0, height: 0, enableInsets: false)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top