DPOTPView icon indicating copy to clipboard operation
DPOTPView copied to clipboard

Change Border Color and text Color instantly

Open taimur opened this issue 3 years ago • 4 comments

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

taimur avatar Sep 01 '21 08:09 taimur

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

sajidjutt7 avatar Sep 25 '21 12:09 sajidjutt7

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

tapan-nathvani avatar Mar 30 '22 05:03 tapan-nathvani

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)

sajidjutt7 avatar Apr 02 '22 08:04 sajidjutt7

Thanks.. I used the same thing.

tapan-nathvani avatar Apr 02 '22 09:04 tapan-nathvani