1

I have made a custom attribute inspector for my text field:

@IBInspectable var bottomColor: UIColor = UIColor.clear {
    didSet {
        if bottomColor == UIColor.clear {
            self.borderStyle = .roundedRect
        } else {
            self.borderStyle = .bezel
        }
        self.setNeedsDisplay()
    }
}

Now I want to set bottomColor to red when the form is submitted with an empty text field. Which would be the best way to do this?

CharonX
  • 2,130
  • 11
  • 33
reza
  • 119
  • 1
  • 11

1 Answers1

2

I'm putting my logic here

For do that you need to add bottom border of UITextField

UITextField border for bottom side only in swift OR How to only show bottom border of UITextField in Swift

Then you need to set color of this bottom border that you want

After remove same you need to set 0 width of bottom border of UITextField clear color of border.

Govaadiyo
  • 5,644
  • 9
  • 43
  • 72