Skip to content

Commit 8aee5a5

Browse files
author
Jishnu Raj T
committed
semanticContentAttribute Support
1 parent 3854112 commit 8aee5a5

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Example/iOSDropDown/ViewController1.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ViewController1: UIViewController {
2222
mainDropDown.optionArray = option.countries
2323
mainDropDown.optionIds = option.ids
2424
mainDropDown.checkMarkEnabled = false
25+
mainDropDown.semanticContentAttribute = .forceRightToLeft
2526
cstmbutn.isHidden = true
2627
customView.isHidden = true
2728
mainDropDown.didSelect{(selectedText , index , id) in

iOSDropDown/Classes/iOSDropDown.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ open class DropDown: UITextField {
1818

1919
@IBInspectable public var rowHeight: CGFloat = 30
2020
@IBInspectable public var rowBackgroundColor: UIColor = .white
21-
@IBInspectable public var itemsColor: UIColor = .gray
21+
@IBInspectable public var itemsColor: UIColor = .darkGray
2222
@IBInspectable public var itemsTintColor: UIColor = .blue
23-
@IBInspectable public var selectedRowColor: UIColor = .cyan
23+
@IBInspectable public var selectedRowColor: UIColor = .systemPink
2424
@IBInspectable public var hideOptionsWhenSelect = true
2525
@IBInspectable public var isSearchEnable: Bool = true {
2626
didSet {
@@ -134,12 +134,18 @@ open class DropDown: UITextField {
134134

135135
func setupUI() {
136136
let size = frame.height
137-
let rightView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: size, height: size))
138-
self.rightView = rightView
139-
rightViewMode = .always
140-
let arrowContainerView = UIView(frame: rightView.frame)
141-
self.rightView?.addSubview(arrowContainerView)
142-
let center = arrowContainerView.center
137+
let arrowView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: size, height: size))
138+
let arrowContainerView = UIView(frame: arrowView.frame)
139+
if semanticContentAttribute == .forceRightToLeft {
140+
leftView = arrowView
141+
leftViewMode = .always
142+
leftView?.addSubview(arrowContainerView)
143+
} else {
144+
rightView = arrowView
145+
rightViewMode = .always
146+
rightView?.addSubview(arrowContainerView)
147+
}
148+
143149
arrow = Arrow(origin: CGPoint(x: center.x - arrowSize / 2, y: center.y - arrowSize / 2), size: arrowSize)
144150
arrowContainerView.addSubview(arrow)
145151

0 commit comments

Comments
 (0)