UISegmentedControl - altering height in Interface Builder

Urizen picture Urizen · Jan 26, 2010 · Viewed 21k times · Source

I'm creating a number of static custom UITableViewCells and have dragged a UISegmentedControl onto one of the custom cells.

Whilst the segmented control allows me to alter its width I cannot alter its height in Interface Builder (that property is greyed out on 44 in the 'size' section of the property inspector).

I know that a UISegmentedControl can be crated with a custom height in code and added to a UITableViewCell. Is there any way to adjust the height of the segmented control in Interface Builder?

Answer

kender picture kender · Dec 31, 2010

You can also open the xib file in any text editor, like Dashcode or MacVim or TextEdit - it's an XML. Then find your element there, in my case it looked like:

<object class="IBUISegmentedControl" id="270020637">
    [...]
    <string key="NSFrame">{{20, 154}, {176, 44}}</string>
    [...]
</object>

Then you can change the 44 into whatever height you want - you'll see the changes in IB.

This works for all elements that can't be changed height in IB - UIPicker also...