I\'m trying to rotate a label on my view 90 degrees. I\'ve tried the two following ways to do it and the label just disappears from the screen. I triple checked that the prope
I am not 100% sure if it works or not but why are you not using M_PI_2
. It's just simple thought that you are assuming Value of Pi
to be 3.14
but the exact value is 3.14159...
I did it like this and it worked fine :
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 70)];
lbl.text = @"New";
lbl.backgroundColor = [UIColor clearColor];
lbl.textColor = [UIColor whiteColor];
lbl.highlightedTextColor = [UIColor blackColor];
lbl.font = [UIFont systemFontOfSize:12];
lbl.transform = CGAffineTransformMakeRotation(M_PI_2);
[self.view addSubview:lbl];
You can also check Answers from these Questions :
How to Render a rotated UIlabel
Rotating UILabel at its center
Hope it will be helpful for you.