diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index 25fa2b2..97209df 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -152,6 +152,11 @@ public final class DropDown: UIView { didSet { setNeedsUpdateConstraints() } } + // The height of the drop down + public var height: CGFloat = 0.0 { + didSet{ setNeedsUpdateConstraints() } + } + /** arrowIndication.x @@ -569,7 +574,7 @@ extension DropDown { widthConstraint.constant = layout.width heightConstraint.constant = layout.visibleHeight - tableView.isScrollEnabled = layout.offscreenHeight > 0 + tableView.isScrollEnabled = true DispatchQueue.main.async { [weak self] in self?.tableView.flashScrollIndicators() @@ -1019,7 +1024,11 @@ extension DropDown { /// Returns the height needed to display all cells. fileprivate var tableHeight: CGFloat { - return tableView.rowHeight * CGFloat(dataSource.count) + if height == 0.0 { + return tableView.rowHeight * CGFloat(dataSource.count) + } else { + return height + } } //MARK: Objective-C methods for converting the Swift type Index diff --git a/README.md b/README.md index c423fe5..07c476c 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,9 @@ dropDown.selectionAction = { [unowned self] (index: Int, item: String) in // Will set a custom width instead of the anchor view width dropDownLeft.width = 200 + +// Will set a custom height to drop down +dropDownLeft.height = 160 ``` Display actions: