0

Say you have:

class TestField: UITextField {
    override init(frame: CGRect) {
        var f = frame
        f.size.height = 50.0
        super.init(frame: f)
    }

Of course when you init it (in code) it will force the height to be 50.

But say I want TestField to be actually loaded from storyboard:

class TestField: UITextField {
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        print("generally you can add some setup here")
    }

You can add some setup there to, example, change colors and so on.

But.

What I want is that the height of TestFields will be "50" (not the usual 25) when they are created.

Is there actually any way to do this?

As a bonus, it would be great if the height was even 50 (rather than 25) in storyboard (in an IBDesignable manner).

How to do?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Fattie
  • 27,874
  • 70
  • 431
  • 719

0 Answers0