Luca
Luca

Reputation: 303

@IBDesignable UIView with fixed height

I have a custom control (xib + UIView subclass).

I'd like my control to have a computed height, like UITextField or ProgressBar, so I'd like IB not to show me the UIView resize knobs on each side, but only on the left and right of my custom control. In UITextField height field in property inspector is ghosted, so you can't modify it from Interface Builder.

I searched StackOverflow, and found this Make a fixed size UIView, like UISwitch (using IBDesignable), but it isn't what I am trying to achieve.

Thank you for your help, Luca-

Upvotes: 2

Views: 1455

Answers (2)

Shaheen M Basheer
Shaheen M Basheer

Reputation: 1010

I believe that you want to disable height in Size inspector in right utilities panel, just for your custom control like segment control and fixed height text field. As of now, this is not possible. Using IBInspectable, you will only be able to display your variables in Attribute Inspector. The other option you have is to resize your control within the code, every time it loads.

Upvotes: 2

Scott Thompson
Scott Thompson

Reputation: 23701

One way to accomplish what you want is to add height and width constraints on the view using Auto Layout. You can add an IBOutlet to the constraints in Interface Builder in case you need to manipulate them at run time.

Upvotes: 1

Related Questions