Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override init(frame: CGRect) {
- super.init(frame: frame)
- shared()
- commonInit()
- if let superview = superview {
- setupAutocompleteTable(superview)
- }
- }
- public override func willMove(toSuperview newSuperview: UIView?) {
- super.willMove(toSuperview: newSuperview)
- commonInit()
- setupAutocompleteTable(newSuperview!)
- }
- lazy var tableView: UITableView = {
- let tableView = UITableView()
- tableView.translatesAutoresizingMaskIntoConstraints = false
- tableView.dataSource = self
- tableView.delegate = self
- tableView.rowHeight = autoCompleteCellHeight
- tableView.isHidden = hidesWhenEmpty ?? true
- tableView.layer.borderColor = UIColor.lightGray.cgColor
- tableView.layer.borderWidth = 0.5
- tableView.layer.zPosition = CGFloat(Float.greatestFiniteMagnitude)
- return tableView
- }()
- fileprivate func setupAutocompleteTable(_ view: UIView) {
- autoCompleteTableMargin = 10.0
- view.addSubview(tableView)
- tableView.topAnchor.constraint(equalTo: view.bottomAnchor, constant: 20).isActive = true
- tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
- tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
- tableView.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: 0).isActive = true
- tableView.heightAnchor.constraint(equalToConstant: 30).isActive = true
- autoCompleteTableView = tableView
- autoCompleteTableHeight = 200.0
- }
- lazy var searchField: GooglePlaceSearchField = {
- let field = GooglePlaceSearchField()
- field.translatesAutoresizingMaskIntoConstraints = true
- field.placeholder = "Enter area, city .."
- field.setIcon(#imageLiteral(resourceName: "zamasearch"))
- field.highLightTypeTextedEnabled = true
- return field
- }()
- view.addSubview(searchBgView)
- searchBgView.addSubview(searchField)
- 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)
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement