Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to set uppercase on fields #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SVPinView/Source/Classes/SVPinField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
import UIKit

class SVPinField: UITextField {

var isAllUppercased: Bool = false {
didSet {
if isAllUppercased {
self.autocapitalizationType = .allCharacters
} else {
self.autocapitalizationType = .none
}
}
}

var deleteButtonAction: SVPinViewDeleteButtonAction = .deleteCurrentAndMoveToPrevious
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(UIResponderStandardEditActions.copy(_:)) ||
Expand Down
8 changes: 8 additions & 0 deletions SVPinView/Source/Classes/SVPinView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public class SVPinView: UIView {
public var becomeFirstResponderAtIndex: Int? = nil
public var isContentTypeOneTimeCode: Bool = true
public var shouldDismissKeyboardOnEmptyFirstField: Bool = false
public var shouldUppercase: Bool = false

public var pinInputAccessoryView: UIView? {
didSet { refreshPinView() }
}
Expand Down Expand Up @@ -245,6 +247,11 @@ public class SVPinView: UIView {
print("-----------------------------------")
}

public func setAllUppercased() {
self.shouldUppercase = true
collectionView.reloadData()
}

// MARK: - Public methods -

/// Returns the entered PIN; returns empty string if incomplete
Expand Down Expand Up @@ -339,6 +346,7 @@ extension SVPinView : UICollectionViewDataSource, UICollectionViewDelegate, UICo
textField.tintColor = self.tintColor
textField.font = self.font
textField.deleteButtonAction = self.deleteButtonAction
textField.isAllUppercased = shouldUppercase
if #available(iOS 12.0, *), indexPath.row == 0, isContentTypeOneTimeCode {
textField.textContentType = .oneTimeCode
}
Expand Down