🖋 Apple TV | Simple code screen
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Example
TvCodeScreen.xcworkspace
TvCodeScreen
.gitignore
.travis.yml
LICENSE
Podfile
Podfile.lock
README.md
TvCodeScreen.podspec

README.md

Version License Platform Build Status codecov.io

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