TvCodeScreen 0.1.1

TvCodeScreen 0.1.1

TestsTested โœ—
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2017
SwiftSwift Version 3.0
SPMSupports SPM โœ—

Maintained by Macabeus.



  • By
  • Bruno Macabeus

TvCodeScreen

Simple code screen for tvOS

You can download this repository and see this example app.

How to use

Install

In Podfile add

pod 'TvCodeScreen'

and use pod install.

Setup

Create a new UIView and set CodeInputView as a custom class

In Attribute Inspector tab you can change the code length and colors. The default code length value is 6 characters.

Then, your view controller need subscriber the CodeInputViewDelegate protocol. For example:

class ViewController: UIViewController {

    @IBOutlet weak var myCodeInputView: CodeInputView!
    @IBOutlet weak var labelResult: UILabel!
    
    override func viewDidLoad() {
        myCodeInputView.delegate = self
    }
}

extension ViewController: CodeInputViewDelegate {
    
    func finishTyping(_ codeInputView: CodeInputView, codeText: String) {
        if codeText == "42" {
            labelResult.text = "Yes! Good number! ๐ŸŽ‰"
        } else {
            labelResult.text = "No! Wrong number! ๐Ÿ’ฅ"
        }
    }
}

The function finishTyping(codeInputView:codeText:) is called when the user fill the code, and the parameter codeText is the text typed by user.

TODO

  • [ ] Use dynamic type
  • [ ] Suport for letters

Maintainer:

macabeus ย ยทย  GitHub @macabeus