Skip to content

implement FasterVerificationCode programatically #1

@d33pak-s1ngh

Description

@d33pak-s1ngh

Hello @posix88 i am new to swift and ios. I want to implement this otp text field in my verfication view controller programatically. Do you have any example for this it will be help ful.

Following code i have tried
`

lazy var newVerification: VerificationCodeView = {
        let vv = VerificationCodeView()
        vv.translatesAutoresizingMaskIntoConstraints = false

    vv.setLabelNumber(6)
    vv.delegate = self
    vv.labelHasBorder = true
    vv.borderHeigth = 1
    vv.labelBorderColor = UIColor.black
    vv.labelErrorColor = UIColor.red
    vv.labelTextColor = UIColor.black
    //vv.labelBackgroundColor =
    vv.labelWidth = 24
    vv.isNumeric = true
    vv.labelSpacing = 16
    
    
    return vv
}()

func setupCode(){
    
    view.addSubview(newVerification)
    newVerification.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
    newVerification.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
    if #available(iOS 11.0, *) {
        newVerification.topAnchor.constraint(equalTo: view.topAnchor,constant: 50).isActive = true
    } else {
        // Fallback on earlier versions
    }
    newVerification.heightAnchor.constraint(equalToConstant: 80).isActive = true
    
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions