From f42ec2dcd0b730571f3251fe5014572fe20e92ce Mon Sep 17 00:00:00 2001 From: BerkinSili Date: Wed, 7 Sep 2022 23:51:52 +0300 Subject: [PATCH 1/2] - add text alignment to DropDownAppearance --- DropDown/helpers/DPDConstants.swift | 1 + DropDown/src/DropDown.swift | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/DropDown/helpers/DPDConstants.swift b/DropDown/helpers/DPDConstants.swift index 52047beb..c32aa2b2 100644 --- a/DropDown/helpers/DPDConstants.swift +++ b/DropDown/helpers/DPDConstants.swift @@ -35,6 +35,7 @@ internal struct DPDConstant { static let CornerRadius: CGFloat = 2 static let RowHeight: CGFloat = 44 static let HeightPadding: CGFloat = 20 + static let TextAlignment: NSTextAlignment = .left struct Shadow { diff --git a/DropDown/src/DropDown.swift b/DropDown/src/DropDown.swift index f41e8ddd..285d5d2a 100644 --- a/DropDown/src/DropDown.swift +++ b/DropDown/src/DropDown.swift @@ -324,6 +324,15 @@ public final class DropDown: UIView { public var downScaleTransform = DPDConstant.Animation.DownScaleTransform { willSet { tableViewContainer.transform = newValue } } + + /** + The text alignment of the optionLabel for each cells of the drop down. + + Changing the alignment color automatically reloads the drop down. + */ + @objc public dynamic var textAlignment = DPDConstant.UI.TextAlignment { + didSet { reloadAllComponents() } + } /** The color of the text for each cells of the drop down. @@ -1078,6 +1087,7 @@ extension DropDown: UITableViewDataSource, UITableViewDelegate { cell.selectedBackgroundColor = selectionBackgroundColor cell.highlightTextColor = selectedTextColor cell.normalTextColor = textColor + cell.optionLabel.textAlignment = textAlignment if let cellConfiguration = cellConfiguration { cell.optionLabel.text = cellConfiguration(index, dataSource[index]) From 757e2bcb76236be2aa5e3f0d79e51da18c3371b4 Mon Sep 17 00:00:00 2001 From: BerkinSili Date: Wed, 7 Sep 2022 23:53:28 +0300 Subject: [PATCH 2/2] update setupDefaultAppearance() --- DropDown/src/DropDown+Appearance.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/DropDown/src/DropDown+Appearance.swift b/DropDown/src/DropDown+Appearance.swift index 7ac057da..49271103 100644 --- a/DropDown/src/DropDown+Appearance.swift +++ b/DropDown/src/DropDown+Appearance.swift @@ -28,6 +28,7 @@ extension DropDown { appearance.textColor = DPDConstant.UI.TextColor appearance.selectedTextColor = DPDConstant.UI.SelectedTextColor appearance.textFont = DPDConstant.UI.TextFont + appearance.textAlignment = DPDConstant.UI.TextAlignment } }