Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save m760622/dd24dc14f7ea823461dcd01656abd43f to your computer and use it in GitHub Desktop.
Save m760622/dd24dc14f7ea823461dcd01656abd43f to your computer and use it in GitHub Desktop.
Turns a UISegmentedControl into a vertical layout.
import UIKit
extension UISegmentedControl {
func goVertical() {
self.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2))
for segment in self.subviews {
for segmentSubview in segment.subviews {
if segmentSubview is UILabel {
(segmentSubview as UILabel).transform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2))
}
}
}
}
func restoreHorizontal() {
self.transform = CGAffineTransformIdentity
for segment in self.subviews {
for segmentSubview in segment.subviews {
if segmentSubview is UILabel {
(segmentSubview as UILabel).transform = CGAffineTransformIdentity
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment