I'm working on an iOS project that requires the basic UISegmentedControl
but, instead of having the normal left to right layout it requires a top to bottom layout. I have looked in stack overflow and found some libraries that does this. Is there a method I can achieve this without a library?
Asked
Active
Viewed 69 times
0

Frankenstein
- 15,732
- 4
- 22
- 47
-
1Libraries are also code written by someone. If you want to know how to achieve that than you should examine those libraries. – Bista Mar 06 '18 at 04:45
-
https://stackoverflow.com/questions/3490358/can-i-show-an-uisegmentedcontrol-object-in-vertical – PPL Mar 06 '18 at 04:58
2 Answers
1
You can achieve UISegmentedControl
top and bottom layout with below code:
Swift 4:
segmentControl.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2)
Objective-C
self.segmentControl.transform = CGAffineTransformMakeRotation(- M_PI / 2.0);

iVarun
- 6,496
- 2
- 26
- 34
0
Yes, you can rotate the texts inside by doing like this
for view in yourSegmentedControl.subviews {
for subview in view.subviews {
if subview is UILabel{
subview.transform = CGAffineTransform(rotationAngle:CGFloat(-Double.pi / 2.0))
}
}
}

Himanth
- 2,381
- 3
- 28
- 41