diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Demo/ViewController.swift b/Demo/ViewController.swift index c5130f0f..f9f8ef8b 100644 --- a/Demo/ViewController.swift +++ b/Demo/ViewController.swift @@ -176,7 +176,7 @@ class ViewController: UIViewController { "Asus Zenfone Max 4G", "Apple Watwh | Sport Edition" ] - + chooseArticleDropDown.heightofDropdown = 150 // Action triggered on selection chooseArticleDropDown.selectionAction = { [weak self] (index, item) in self?.chooseArticleButton.setTitle(item, for: .normal) diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index f41e8ddd..1c8489c6 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -153,6 +153,10 @@ public final class DropDown: UIView { public var width: CGFloat? { didSet { setNeedsUpdateConstraints() } } + + public var heightofDropdown: CGFloat? { + didSet { setNeedsUpdateConstraints() } + } /** arrowIndication.x @@ -578,9 +582,19 @@ extension DropDown { xConstraint.constant = layout.x yConstraint.constant = layout.y widthConstraint.constant = layout.width - heightConstraint.constant = layout.visibleHeight + + // this is for the custom height of dropdown + if let height = self.heightofDropdown { + if layout.visibleHeight >= height { + heightConstraint.constant = self.heightofDropdown ?? layout.visibleHeight + } else { + heightConstraint.constant = layout.visibleHeight + } + } else { + heightConstraint.constant = layout.visibleHeight + } - tableView.isScrollEnabled = layout.offscreenHeight > 0 + tableView.isScrollEnabled = true DispatchQueue.main.async { [weak self] in self?.tableView.flashScrollIndicators()