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+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 } } 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])