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
1 change: 1 addition & 0 deletions DropDown/helpers/DPDConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal struct DPDConstant {
static let CornerRadius: CGFloat = 2
static let RowHeight: CGFloat = 44
static let HeightPadding: CGFloat = 20
static let NumblerOfLines: Int = 1

struct Shadow {

Expand Down
18 changes: 18 additions & 0 deletions DropDown/src/DropDown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ public final class DropDown: UIView {
didSet { reloadAllComponents() }
}

/**
Changing the text lines automatically reloads the drop down.

Default - 1
*/
@objc public dynamic var numberOfLines = DPDConstant.UI.NumblerOfLines {
didSet { reloadAllComponents() }
}

/**
The NIB to use for DropDownCells

Expand Down Expand Up @@ -1075,6 +1084,7 @@ extension DropDown: UITableViewDataSource, UITableViewDelegate {

cell.optionLabel.textColor = textColor
cell.optionLabel.font = textFont
cell.optionLabel.numberOfLines = numberOfLines
cell.selectedBackgroundColor = selectionBackgroundColor
cell.highlightTextColor = selectedTextColor
cell.normalTextColor = textColor
Expand All @@ -1088,6 +1098,14 @@ extension DropDown: UITableViewDataSource, UITableViewDelegate {
customCellConfiguration?(index, dataSource[index], cell)
}

public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}

public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return cellHeight
}

public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.isSelected = selectedRowIndices.first{ $0 == (indexPath as NSIndexPath).row } != nil
}
Expand Down