Can I show an UISegmentedControl object in vertical?
You can always modify the transform on the segmented control.
segmentedControl.transform = CGAffineTransformMakeRotation(M_PI / 2.0);
+1 for Ben's answer, although rotating the segmented control also rotates the text inside. Never fear! We just have to rotate the inside labels, like so:
NSArray *arr = [segmentedControl subviews];
for (int i = 0; i < [arr count]; i++) {
UIView *v = (UIView*) [arr objectAtIndex:i];
NSArray *subarr = [v subviews];
for (int j = 0; j < [subarr count]; j++) {
if ([[subarr objectAtIndex:j] isKindOfClass:[UILabel class]]) {
UILabel *l = (UILabel*) [subarr objectAtIndex:j];
l.transform = CGAffineTransformMakeRotation(- M_PI / 2.0); //do the reverse of what Ben did
}
}
}
Swift 2 version:
for view in segmentedControl.subviews {
for subview in view.subviews {
if subview.isKindOfClass(UILabel) {
subview.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI / 2.0))
}
}
}