AssistoLab / DropDown

A Material Design drop down for iOS
MIT License
2.44k stars 622 forks source link

Bottom offset not working #241

Open willnix86 opened 5 years ago

willnix86 commented 5 years ago

I have the following code set up...

self.addSubview(button)
        button.backgroundColor = backgroundColor
        button.setTitleColor(UIColor.black, for: .normal)
        button.addTarget(self, action: #selector(toggleDropdown), for: .touchUpInside)
        button.snp.makeConstraints { (make) -> Void in
            make.left.right.equalTo(self)
            make.height.equalTo(45)
        }

        self.addSubview(dropdown)
        dropdown.anchorView = button
        dropdown.dataSource = self.options
        dropdown.direction = .bottom
        dropdown.bottomOffset = CGPoint(x: 0, y:(dropdown.anchorView?.plainView.bounds.height)!)
        dropdown.selectionAction = { [unowned self] (index: Int, item: String) in
            self.button.setTitle(item, for: .normal)
            print("Selected item: \(item)")
        }

But the dropdown still covers the button (it's anchorview). What am I missing, or is something broken?

OleksiiShulzhenko commented 4 years ago

try to use CGPoint(x: 0, y: button.frame.height)