Datt1994 / DPOTPView

Customisable OTP view and Passcode view
Apache License 2.0
65 stars 20 forks source link

Change Border Color and text Color instantly #10

Open taimur opened 3 years ago

taimur commented 3 years ago

I want to change borderColor and textColor instantly as soon user enters wrong OTP and then reset the colors. I have used these its not working. It works when user removes the character

otpView.borderColorTextField = app.theme.red
otpView.textColorTextField = app.theme.red

image

sajidjutt7 commented 2 years ago

Getting same issue. Cannot assign all textfields colour at them same time. otpView.borderColorTextField =.red only sets the border colour when we focus given to any textfield on touch. Please fix it

tapan-nathvani commented 2 years ago

Hi, Any update on this? Even we need to achieve the same thing..

sajidjutt7 commented 2 years ago

I copy the "DPOTPView.swift" class into my project. Then add this function in that class.

    public func setBorderColor(color: UIColor) {
        arrTextFields.forEach {(textField) in
            textField.borderStyle = .none
            textField.layer.masksToBounds = false
            textField.layer.shadowColor = color
            textField.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
            textField.layer.shadowOpacity = 1.0
            textField.layer.shadowRadius = 0.0
        }
    }

Then use this in my swift class as.

txtOTPView.setBorderColor(color: .red)

tapan-nathvani commented 2 years ago

Thanks.. I used the same thing.