i am trying to make a layout, where i don't want to rotate my button, but want to rotate only my text of that button.
So is there any way to do that.?
i am trying to make a layout, where i don't want to rotate my button, but want to rotate only my text of that button.
So is there any way to do that.?
Here is the original label:
Rotate 90 degrees clockwise:
yourLabelName.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2)
Rotate 180 degrees:
yourLabelName.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
Rotate 90 degrees counterclockwise:
yourLabelName.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2)
There are 2π radians in a full circle (360 degrees).
Swift includes the useful constant CGFloat.pi.
CGFloat.pi = π = 180 degrees
CGFloat.pi / 2 = π/2 = 90 degrees
You can access button.titleLabel
example:
button.titleLabel?.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2)
opposite angle
button.titleLabel?.transform = CGAffineTransform(rotationAngle: -CGFloat.pi / 2)