Skip to content

Commit

Permalink
Fixed clear button problem
Browse files Browse the repository at this point in the history
  • Loading branch information
blsage committed Oct 22, 2020
1 parent db1d5d8 commit 55a2a1a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Sources/iTextField/iTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public struct iTextField: UIViewRepresentable {

public func textFieldShouldClear(_ textField: UITextField) -> Bool {
shouldClear()
text = ""
return false
}
}
Expand Down Expand Up @@ -323,17 +324,11 @@ extension iTextField {
}

/// Modifies whether and when the text field **clear button** appears on the view. ⭕️ ❌
///
/// Options:
/// 1. `.never`: The clear button is never visible
/// 2. `.whileEditing`: The clear button is visible when the user is editing
/// 3. `.unlessEditing`: The clear button is only visible when the user is not editing
/// 4. `.always`: The clear button is always visible
/// - Parameter mode: When the clear button should be visible
/// - Parameter showsButton: Whether the clear button should be visible
/// - Returns: A text field with updated clear button settings
public func showsClearButton(_ mode: UITextField.ViewMode) -> iTextField {
public func showsClearButton(_ showsButton: Bool) -> iTextField {
var view = self
view.clearButtonMode = mode
view.clearButtonMode = showsButton ? .always : .never
return view
}

Expand Down

0 comments on commit 55a2a1a

Please sign in to comment.