Skip to content

Commit 750681c

Browse files
committed
Toggle the left edge constraint before icon is added to avoid layout conflicts
1 parent f2712d1 commit 750681c

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

Source/ICTokenField.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,12 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
148148
private var leftView: UIView? {
149149
didSet {
150150
oldValue?.removeFromSuperview()
151+
leftEdgeConstraint.active = leftView == nil
151152
if let icon = leftView {
152153
addSubview(icon)
153154
icon.translatesAutoresizingMaskIntoConstraints = false
154155
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[icon]-10-[wrapper]", options: [], metrics: nil, views: ["icon": icon, "wrapper": scrollView]))
155156
addConstraint(NSLayoutConstraint(item: icon, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1, constant: 0))
156-
leftEdgeConstraint.active = false
157-
} else {
158-
leftEdgeConstraint.active = true
159157
}
160158
}
161159
}

0 commit comments

Comments
 (0)