Skip to content

Instantly share code, notes, and snippets.

@wpK
Created March 28, 2016 21:57
Show Gist options
  • Save wpK/40551dbde865b277cc88 to your computer and use it in GitHub Desktop.
Save wpK/40551dbde865b277cc88 to your computer and use it in GitHub Desktop.
ASEditableTextNode secureTextEntry Example
import UIKit
import AsyncDisplayKit
class TextSecureEntryViewController: UIViewController {
// MARK: Properties
private let editableTextNode: ASEditableTextNode
// MARK: Lifecycle
required init() {
self.editableTextNode = ASEditableTextNode()
super.init(nibName: nil, bundle: nil)
}
required init(coder aDecoder: NSCoder) {
fatalError("storyboards are incompatible with truth and beauty")
}
// MARK: UIViewController
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.darkGrayColor()
self.editableTextNode.attributedPlaceholderText = NSAttributedString(string: "Password")
self.editableTextNode.textView.secureTextEntry = true
self.editableTextNode.backgroundColor = UIColor.whiteColor()
self.editableTextNode.cornerRadius = 4
self.view.addSubview(self.editableTextNode.view)
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
self.editableTextNode.measure(self.view.frame.size)
self.editableTextNode.frame = CGRectMake(
((self.view.bounds.size.width - 150) / 2),
(self.view.bounds.size.height - self.editableTextNode.calculatedSize.height) / 2,
150,
self.editableTextNode.calculatedSize.height)
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment