Reputation: 253
I rotated a Segmented Control in swift, in order to have a vertical Control. but I wanna rotate the Title Label in 90 degrees
With this code, I can change Title text and color (in Red) as well, but I can't rotate Label, I don't know why.
for view in cell.mySegmentedControl.subviews {
for subview in view.subviews {
if subview is UILabel {
let sub = subview as! UILabel
sub.transform = CGAffineTransform(rotationAngle: .pi/4)
sub.textColor = UIColor.red
sub.text = "OO"
}
}
}
Does anyone know the reason?
Upvotes: 0
Views: 506
Reputation: 74
I believe this is the default behavior of the UISegment Color.
What I would recommend is creating a custom Segmented view using Vertical Stack View! Add the labels to the Stack View and customize them. This would be easier and more convenient
Upvotes: 0