How to change the height of the UISegmentedControl?]
By setting segmentedControl.translatesAutoresizingMaskIntoConstraints = false
you're losing the default constraints.
If you are happy with the appearance and layout of the segmented control, you just want to change its height, try this approach:
// probably in
override func viewDidLoad() {
super.viewDidLoad()
let segmentedControl = UISegmentedControl(items: ["Segment1", "Segment2"])
segmentedControl.frame.size.height = 50.0
tableView.tableHeaderView = segmentedControl
}
iOS: change the height of UISegmentedcontrol
Yes, you can use [mySegmentedControl setFrame:frame]
in code. It is unfortunate that you can't do this in IB.
So, if you just want to change the height:
CGRect frame= mySegmentedControl.frame;
[mySegmentedControl setFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, fNewHeight)];
Change the height of UISegmentedControl in iOS
If you have autolayout, set the constraints of the UISegmentedControl. Please see pic of where's easiest to set this, make sure width and height are ticked, plus vertical and horizontal space constraints (select where lines that are deep orange in pic).
Now that you have this, control-drag the constraint that sets the height of the segmented control to your header file and name it something like segmentedControlHeightConstraint
.
Once you have done that, within your viewDidLoad in your view controller implementation file add this code
self.segmentedControlHeightConstraint.constant = 50; // or whatever height you wish
This is the best way using auto layout to set the height for this.
Hope this helps
UISegmentedControl - altering height in Interface Builder
No, it must be done in code. See this question.
Related Topics
How to Get the Custom Overlay for Uiimagepicker Camera to Be Full Screen in iOS 7
Using Global Variables in Objective-C
Uitableview Backgroundcolor Always White on iPad
iOS Extensions with Multiple Targets
Status Bar Showing Black Text, Only on iPhone 6 iOS 8 Simulator
Uilabel Text Not Being Updated
App Transport Security Xcode 7 Beta 6
How to Set the Position of the Cursor in Uitextview
How to Obtain Country, State, City from Reversegeocodecoordinate
Warp \ Bend Effect on a Uiview
How to Compare Two Strings Ignoring Case in Swift Language
How to Enable Swipe to Delete Cell in a Tableview
How to Programmatically Check Support of 'Face Id' and 'Touch Id'
Detect Shake Gesture iOS Swift
Custom Font in iOS Not Working
Ios: Can't Save File to 'Application Support' Folder, But Can to 'Documents'