From 4853e41989dfa2f5c2fd90549dbc75e47583ac0b Mon Sep 17 00:00:00 2001 From: Gizem Fitoz Date: Wed, 29 May 2019 23:21:24 +0300 Subject: [PATCH 1/6] dropdown height added --- DropDown/src/DropDown.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index 25fa2b2..2c9f777 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -73,6 +73,12 @@ public final class DropDown: UIView { } + public var dropDownHeight: CGFloat = 0.0 { + didSet{ + updateConstraints() + } + } + //MARK: - Properties /// The current visible drop down. There can be only one visible drop down at a time. @@ -569,7 +575,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 +1025,11 @@ extension DropDown { /// Returns the height needed to display all cells. fileprivate var tableHeight: CGFloat { - return tableView.rowHeight * CGFloat(dataSource.count) + if dropDownHeight == 0.0 { + return tableView.rowHeight * CGFloat(dataSource.count) + } else { + return dropDownHeight + } } //MARK: Objective-C methods for converting the Swift type Index From d44840ce5832b6ab2acd2953739cb68c18cf5cdf Mon Sep 17 00:00:00 2001 From: Gizem Fitoz Date: Wed, 29 May 2019 23:49:09 +0300 Subject: [PATCH 2/6] readme updated --- DropDown/src/DropDown.swift | 9 +++------ README.md | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index 2c9f777..0ff9098 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -72,12 +72,6 @@ public final class DropDown: UIView { case bottom } - - public var dropDownHeight: CGFloat = 0.0 { - didSet{ - updateConstraints() - } - } //MARK: - Properties @@ -106,6 +100,9 @@ public final class DropDown: UIView { return imgv }() + public var dropDownHeight: CGFloat = 0.0 { + didSet{ setNeedsUpdateConstraints() } + } /// The view to which the drop down will displayed onto. public weak var anchorView: AnchorView? { diff --git a/README.md b/README.md index c423fe5..f5ed657 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,7 @@ You can customize these properties of the drop down: - `backgroundColor`: the background color of the drop down. - `selectionBackgroundColor`: the background color of the selected cell in the drop down. - `cellHeight`: the height of the drop down cells. +- `dropDownHeight`: the height of the drop down. - `dimmedBackgroundColor`: the color of the background (behind the drop down, covering the entire screen). - `cornerRadius`: the corner radius of the drop down (see [info](#Issues) below if you encounter any issue) - `setupMaskedCorners`: the masked corners of the dropdown. Use this along with `cornerRadius` to set the corner radius only on certain corners. From 29501538206c74d38613e326e96db3c4d9924507 Mon Sep 17 00:00:00 2001 From: Gizem Fitoz Date: Wed, 29 May 2019 23:57:45 +0300 Subject: [PATCH 3/6] `dropDownHeight` renamed as `height` --- DropDown/src/DropDown.swift | 13 +++++++------ README.md | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index 0ff9098..ec7cf4a 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -100,10 +100,6 @@ public final class DropDown: UIView { return imgv }() - public var dropDownHeight: CGFloat = 0.0 { - didSet{ setNeedsUpdateConstraints() } - } - /// The view to which the drop down will displayed onto. public weak var anchorView: AnchorView? { didSet { setNeedsUpdateConstraints() } @@ -155,6 +151,11 @@ public final class DropDown: UIView { didSet { setNeedsUpdateConstraints() } } + // The height of the drop down + public var height: CGFloat = 0.0 { + didSet{ setNeedsUpdateConstraints() } + } + /** arrowIndication.x @@ -1022,10 +1023,10 @@ extension DropDown { /// Returns the height needed to display all cells. fileprivate var tableHeight: CGFloat { - if dropDownHeight == 0.0 { + if height == 0.0 { return tableView.rowHeight * CGFloat(dataSource.count) } else { - return dropDownHeight + return height } } diff --git a/README.md b/README.md index f5ed657..499b348 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ You can customize these properties of the drop down: - `backgroundColor`: the background color of the drop down. - `selectionBackgroundColor`: the background color of the selected cell in the drop down. - `cellHeight`: the height of the drop down cells. -- `dropDownHeight`: the height of the drop down. +- `height`: the height of the drop down. - `dimmedBackgroundColor`: the color of the background (behind the drop down, covering the entire screen). - `cornerRadius`: the corner radius of the drop down (see [info](#Issues) below if you encounter any issue) - `setupMaskedCorners`: the masked corners of the dropdown. Use this along with `cornerRadius` to set the corner radius only on certain corners. From eabfb958b769c87d08a217a54460c64c8201f90a Mon Sep 17 00:00:00 2001 From: Gizem Fitoz Date: Thu, 30 May 2019 00:05:26 +0300 Subject: [PATCH 4/6] readme updated --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 499b348..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: @@ -253,7 +256,6 @@ You can customize these properties of the drop down: - `backgroundColor`: the background color of the drop down. - `selectionBackgroundColor`: the background color of the selected cell in the drop down. - `cellHeight`: the height of the drop down cells. -- `height`: the height of the drop down. - `dimmedBackgroundColor`: the color of the background (behind the drop down, covering the entire screen). - `cornerRadius`: the corner radius of the drop down (see [info](#Issues) below if you encounter any issue) - `setupMaskedCorners`: the masked corners of the dropdown. Use this along with `cornerRadius` to set the corner radius only on certain corners. From 6ad807d4648813afaea7f8b627d7e7a5fa6e75a1 Mon Sep 17 00:00:00 2001 From: Gizem Fitoz Date: Thu, 30 May 2019 00:07:54 +0300 Subject: [PATCH 5/6] revert whitespace change --- DropDown/src/DropDown.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index ec7cf4a..b5938f8 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -72,7 +72,7 @@ public final class DropDown: UIView { case bottom } - + //MARK: - Properties /// The current visible drop down. There can be only one visible drop down at a time. From 4cda38ebae9ef299e9de74c74385f13279e25f97 Mon Sep 17 00:00:00 2001 From: Gizem Fitoz Date: Thu, 30 May 2019 00:08:37 +0300 Subject: [PATCH 6/6] revert whitespace change --- DropDown/src/DropDown.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index b5938f8..97209df 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -100,6 +100,7 @@ public final class DropDown: UIView { return imgv }() + /// The view to which the drop down will displayed onto. public weak var anchorView: AnchorView? { didSet { setNeedsUpdateConstraints() }