Skip to content

Commit e66c047

Browse files
committed
Allow classes to be externally subclassed
1 parent 43de68b commit e66c047

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

Source/KeyboardDismissTextField/ICKeyboardDismissAccessoryView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import UIKit
2828

2929
/// A customized keyboard accessory view with a dismiss button.
3030
@IBDesignable
31-
public class ICKeyboardDismissAccessoryView: UIView {
31+
open class ICKeyboardDismissAccessoryView: UIView {
3232

3333
/// The background color of the button to dismiss keyboard.
3434
@IBInspectable public var buttonColor: UIColor = Constants.ButtonColor {
@@ -73,7 +73,7 @@ public class ICKeyboardDismissAccessoryView: UIView {
7373

7474
// MARK: - UIView
7575

76-
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
76+
open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
7777
for subview in subviews {
7878
if !subview.isHidden && subview.alpha > 0 &&
7979
subview.isUserInteractionEnabled &&
@@ -86,7 +86,7 @@ public class ICKeyboardDismissAccessoryView: UIView {
8686

8787
// MARK: - NSKeyValueCoding
8888

89-
public override func setValue(_ value: Any?, forKey key: String) {
89+
open override func setValue(_ value: Any?, forKey key: String) {
9090
if let color = value as? UIColor, key == "buttonColor" {
9191
buttonColor = color
9292
}

Source/KeyboardDismissTextField/ICKeyboardDismissTextField.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import UIKit
2828

2929
/// A text field that has a button to dismiss keyboard on the input accessory view.
3030
@IBDesignable
31-
public class ICKeyboardDismissTextField: UITextField {
31+
open class ICKeyboardDismissTextField: UITextField {
3232

3333
/// The custom input accessory view with a button to dismiss keyboard.
3434
@IBOutlet public var keyboardAccessoryView: ICKeyboardDismissAccessoryView! {
@@ -55,7 +55,7 @@ public class ICKeyboardDismissTextField: UITextField {
5555

5656
// MARK: - UIResponder
5757

58-
public override func becomeFirstResponder() -> Bool {
58+
open override func becomeFirstResponder() -> Bool {
5959
if UI_USER_INTERFACE_IDIOM() == .phone {
6060
keyboardAccessoryView.alpha = 1
6161
}

Source/TokenField/ICTokenField.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import UIKit
4343

4444
/// A text field that groups input texts with delimiters.
4545
@IBDesignable
46-
public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDelegate {
46+
open class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDelegate {
4747

4848
// MARK: - Public Properties
4949

@@ -130,7 +130,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
130130
}
131131

132132
/// The tint color of icon image and text field.
133-
public override var tintColor: UIColor! {
133+
open override var tintColor: UIColor! {
134134
didSet {
135135
inputTextField.tintColor = tintColor
136136
leftView?.tintColor = tintColor
@@ -223,29 +223,29 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
223223

224224
// MARK: - UIResponder
225225

226-
public override var isFirstResponder: Bool {
226+
open override var isFirstResponder: Bool {
227227
return inputTextField.isFirstResponder || super.isFirstResponder
228228
}
229229

230-
public override func becomeFirstResponder() -> Bool {
230+
open override func becomeFirstResponder() -> Bool {
231231
return inputTextField.becomeFirstResponder()
232232
}
233233

234-
public override func resignFirstResponder() -> Bool {
234+
open override func resignFirstResponder() -> Bool {
235235
super.resignFirstResponder()
236236
return inputTextField.resignFirstResponder()
237237
}
238238

239239
// MARK: - UIView
240240

241-
public override func layoutSubviews() {
241+
open override func layoutSubviews() {
242242
super.layoutSubviews()
243243
layoutTokenTextField()
244244
}
245245

246246
// MARK: - NSKeyValueCoding
247247

248-
public override func setValue(_ value: Any?, forKey key: String) {
248+
open override func setValue(_ value: Any?, forKey key: String) {
249249
switch value {
250250
case let image as UIImage? where key == "icon":
251251
icon = image
@@ -262,23 +262,23 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
262262

263263
// MARK: - UITextFieldDelegate
264264

265-
public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
265+
open func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
266266
tokens.forEach { $0.highlighted = false }
267267
return true
268268
}
269269

270-
public func textFieldDidBeginEditing(_ textField: UITextField) {
270+
open func textFieldDidBeginEditing(_ textField: UITextField) {
271271
delegate?.tokenFieldDidBeginEditing?(self)
272272
}
273273

274-
public func textFieldDidEndEditing(_ textField: UITextField) {
274+
open func textFieldDidEndEditing(_ textField: UITextField) {
275275
completeCurrentInputText()
276276
togglePlaceholderIfNeeded()
277277
tokens.forEach { $0.highlighted = false }
278278
delegate?.tokenFieldDidEndEditing?(self)
279279
}
280280

281-
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
281+
open func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
282282
_ = removeHighlightedToken() // as user starts typing when a token is focused
283283
inputTextField.showsCursor = true
284284

@@ -307,7 +307,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
307307
return true
308308
}
309309

310-
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
310+
open func textFieldShouldReturn(_ textField: UITextField) -> Bool {
311311
completeCurrentInputText()
312312
togglePlaceholderIfNeeded()
313313
delegate?.tokenFieldWillReturn?(self)
@@ -432,7 +432,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
432432
// MARK: - Public Methods
433433

434434
/// Creates a token with the current input text.
435-
public func completeCurrentInputText() {
435+
open func completeCurrentInputText() {
436436
guard let text = inputTextField.text, !text.isEmpty else {
437437
return
438438
}
@@ -443,7 +443,7 @@ public class ICTokenField: UIView, UITextFieldDelegate, ICBackspaceTextFieldDele
443443
}
444444

445445
/// Removes the input text and all displayed tokens.
446-
public func resetTokens() {
446+
open func resetTokens() {
447447
inputTextField.text = nil
448448
tokens.removeAll()
449449
layoutTokenTextField()

0 commit comments

Comments
 (0)