From 35523f5ec7d7ba03096527775e2d1d093aaedaf9 Mon Sep 17 00:00:00 2001 From: Darren Ford Date: Tue, 1 Dec 2020 14:14:46 +1100 Subject: [PATCH] Added secure text field support, delegate support, updated doco --- DSFFloatLabelledTextControl.podspec | 4 ++-- README.md | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/DSFFloatLabelledTextControl.podspec b/DSFFloatLabelledTextControl.podspec index 612adcc..8db189e 100644 --- a/DSFFloatLabelledTextControl.podspec +++ b/DSFFloatLabelledTextControl.podspec @@ -1,9 +1,9 @@ Pod::Spec.new do |s| 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.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 s.homepage = "https://github.com/dagronf/DSFFloatLabelledTextControl" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/README.md b/README.md index c2abba3..626851f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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/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` * 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 +* If you want a secure field, set the `isSecure` property on the control ### 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) +## 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 + +drawing + + ## Credits * Pattern devised by [Matt D. Smith](http://mds.is/matt/) * Read about the pattern [here](http://mds.is/float-label-pattern/) * [UITextField implementation](https://github.com/jverdi/JVFloatLabeledTextField) +## Versions + +* `1.8.0` Added secure text field support, delegate support + ## License ```