I\'m creating a number of static custom UITableViewCells
and have dragged a UISegmentedControl
onto one of the custom cells.
Whilst the segmen
We can set autolayout and then set height, After that we can off autolayout. so It will help for other then ios 6.0 .
I'm not sure in IB, but you could always find the cell in your code and programmatically adjust its UISegmentedControl's height.
To do it inside Interface Builder you can select the control and add frame attribute under "User Defined Runtime Attributes"
You can indirectly change it when you pin the "Height" in Interface Builder (select the segment control then via the menu select Editor -> Pin-> Height
).
This will add a new Height constraint to the list of constraints for that control which you can then edit. Changes directly reflect in InterfaceBuilder as you can see in the Screenshot below.
I want to add to Kender's answer.
If you use storyboard rather than XIB, you will need to add:
<constraint firstAttribute="height" constant="10" id="9Wo-6S-8EM"/>
<constraint firstAttribute="width" constant="201" id="lw7-cq-3XN"/>
The id can be anything unique I guess. Maybe pick some ID and modify one letter?
This is the full code
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="RMR-XS-abw" userLabel="ngentot2">
<constraints>
<constraint firstAttribute="height" constant="10" id="9Wo-6S-8EM"/>
<constraint firstAttribute="width" constant="201" id="lw7-cq-3XN"/>
</constraints>
<segments>
<segment title="First"/>
<segment title="Second"/>
</segments>
</segmentedControl>
I add a userLabel so I can easily find the stuff.
Note: reading the storyboard is very enlightening. Changing storyboard file is VERY dangerous.
No, it must be done in code. See this question.