Added secure text field support, delegate support, updated doco

This commit is contained in:
Darren Ford 2020-12-01 14:14:46 +11:00
parent 8981182b38
commit 35523f5ec7
2 changed files with 28 additions and 3 deletions

View File

@ -1,9 +1,9 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "DSFFloatLabelledTextControl" s.name = "DSFFloatLabelledTextControl"
s.version = "1.7.0" s.version = "1.8.0"
s.summary = "A macOS Cocoa single-line NSTextField that implements the Float Label Pattern" s.summary = "A macOS Cocoa single-line NSTextField that implements the Float Label Pattern"
s.description = <<-DESC s.description = <<-DESC
A macOS Cocoa single-line NSTextField that implements the Float Label Pattern. A macOS Cocoa single-line NSTextField that implements the Float Label Pattern. Supports secure edit fields.
DESC DESC
s.homepage = "https://github.com/dagronf/DSFFloatLabelledTextControl" s.homepage = "https://github.com/dagronf/DSFFloatLabelledTextControl"
s.license = { :type => "MIT", :file => "LICENSE" } s.license = { :type => "MIT", :file => "LICENSE" }

View File

@ -1,6 +1,6 @@
# macOS Float Label Pattern Text Field # macOS Float Label Pattern Text Field
A macOS Cocoa single-line NSTextField that implements the Float Label Pattern. You can read about the float pattern [here](http://mds.is/float-label-pattern/). Usable in Swift and Objective-C projects. A macOS Cocoa single-line NSTextField that implements the Float Label Pattern. You can read about the float pattern [here](http://mds.is/float-label-pattern/). Usable in Swift and Objective-C projects. Supports secure edit fields.
![](https://img.shields.io/github/v/tag/dagronf/DSFFloatLabelledTextControl) ![](https://img.shields.io/badge/macOS-10.11+-red) ![](https://img.shields.io/badge/Swift-5.0-orange.svg) ![](https://img.shields.io/github/v/tag/dagronf/DSFFloatLabelledTextControl) ![](https://img.shields.io/badge/macOS-10.11+-red) ![](https://img.shields.io/badge/Swift-5.0-orange.svg)
![](https://img.shields.io/badge/License-MIT-lightgrey) [![](https://img.shields.io/badge/pod-compatible-informational)](https://cocoapods.org) [![](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager) ![](https://img.shields.io/badge/License-MIT-lightgrey) [![](https://img.shields.io/badge/pod-compatible-informational)](https://cocoapods.org) [![](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)
@ -33,6 +33,7 @@ Copy the `DSFFloatLabelledTextField.swift` into your project. This class inheri
* Drop in a new Text Field into your canvas and set its class to `DSFFloatLabelledTextField` * Drop in a new Text Field into your canvas and set its class to `DSFFloatLabelledTextField`
* Set the size and style of your primary font as you would a regular text field * Set the size and style of your primary font as you would a regular text field
* Set the size of the secondary font via the attributes inspector for the control * Set the size of the secondary font via the attributes inspector for the control
* If you want a secure field, set the `isSecure` property on the control
### Dynamically ### Dynamically
@ -53,12 +54,36 @@ This control inherits from `NSTextField`, so all `NSTextField` functionalities (
`placeholderSpacing` - the distance between the text field text and the floating label (in px) `placeholderSpacing` - the distance between the text field text and the floating label (in px)
## Delegate Handling
You can specify a delegate (`floatLabelDelegate`), either programatically or via Interface Builder, to receive additional information regarding the actions of the control.
```swift
@objc public protocol DSFFloatLabelledTextFieldDelegate: NSObjectProtocol {
/// Called when the label is shown or hidden
@objc optional func floatLabelledTextField(_ field: DSFFloatLabelledTextField, didShowFloatingLabel didShow: Bool)
/// Called when the field becomes or loses first responder status
@objc optional func floatLabelledTextField(_ field: DSFFloatLabelledTextField, didFocus: Bool)
/// Called when the content of the field changes
@objc optional func floatLabelledTextFieldContentChanged(_ field: DSFFloatLabelledTextField)
}
```
## Screenshot
<img src="https://github.com/dagronf/dagronf.github.io/blob/master/art/projects/DSFFloatingLabel/light-mode-secure-field.png?raw=true" alt="drawing" width="265"/>
## Credits ## Credits
* Pattern devised by [Matt D. Smith](http://mds.is/matt/) * Pattern devised by [Matt D. Smith](http://mds.is/matt/)
* Read about the pattern [here](http://mds.is/float-label-pattern/) * Read about the pattern [here](http://mds.is/float-label-pattern/)
* [UITextField implementation](https://github.com/jverdi/JVFloatLabeledTextField) * [UITextField implementation](https://github.com/jverdi/JVFloatLabeledTextField)
## Versions
* `1.8.0` Added secure text field support, delegate support
## License ## License
``` ```