Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 16 additions & 2 deletions DropDown/src/DropDown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public final class DropDown: UIView {
public var width: CGFloat? {
didSet { setNeedsUpdateConstraints() }
}

public var heightofDropdown: CGFloat? {
didSet { setNeedsUpdateConstraints() }
}

/**
arrowIndication.x
Expand Down Expand Up @@ -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()
Expand Down