Reputation: 8489
I am creating a UIButton with interface builder of size 30px width and 164px height.
I want to rotate title of UIButton to 90 degrees.
I am using following code for rotation
// leftNavBtn1 is a UIButton
self.leftNavBtn1.titleLabel.transform = CGAffineTransformMakeRotation(-M_PI / 2);
The problem is after rotation the label cuts off. I have tried to programatically set title but its not work.
I want to achieve like this
What i am getting
Upvotes: 1
Views: 1088
Reputation: 463
Maybe it's stupid, but have you tried creating a label over your button and then apply the same rotation?
It's not elegant but can work
Upvotes: 0
Reputation: 17705
The titleLabel
property is primarily used to configure the text of the button, not its bounds.
I don't think you can achieve what you want to achieve.
If I understand you correctly, you make a button with a small width and big height in interface builder, then set the transformation on the label of the button to 90º, and then expect the button to behave as if the width became the height and vice versa.
I suppose you could still set the button in interface builder, but make it horizontal, as if it's rotated -90º, and then set the transformation on the UIButton in viewDidLoad
Upvotes: 1