class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
loadViews(in: view)
}
// MARK: View
private func loadViews(in box: UIView) {
box.backgroundColor = .lightGray
box.addSubview(mhField)
[mhField].forEach({
$0.translatesAutoresizingMaskIntoConstraints = false
})
NSLayoutConstraint.activate([
mhField.centerYAnchor.constraint(equalTo: box.centerYAnchor, constant: 0.0),
mhField.leftAnchor.constraint(equalTo: box.leftAnchor, constant: 0.0),
mhField.rightAnchor.constraint(equalTo: box.rightAnchor, constant: 0.0),
// Static constraint needed.
mhField.heightAnchor.constraint(equalToConstant: 64.0),
])
}
private func shouldSendCode(_ code: String) {
let message = "shouldSendCode, code=\(code)"
print("MOON__Log" + message)
let alert = UIAlertController(title: "Hint", message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "ok", style: .default))
present(alert, animated: true)
}
private lazy var mhField: MHVerifyCodeView = {
let field = MHVerifyCodeView { [weak self] code in
self?.shouldSendCode(code)
}
return field
}()
}
2024/03/29. Completely refactored by darkThanBlack.
2020/04/30. Created by feaskters.
MHVerifyCodeView is available under the MIT license. See the LICENSE file for more info.