iOS - 尝试旋转文字标签,标签消失 [英] iOS - trying to rotate a text label and the label disappears
本文介绍了iOS - 尝试旋转文字标签,标签消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的视图上旋转一个标签90度。我试过以下两种方法来做,标签只是从屏幕上消失。我三次检查属性是否正确附加。任何想法?
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 properties are properly attached. Any thoughts?
尝试一个:
// rotating labels 90 degrees
self.labelCloseScroll.transform = CGAffineTransformMakeRotation (3.14/2);
尝试两个:
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2);
rotate = CGAffineTransformScale(rotate, 1, 1);
[self.labelCloseScroll setTransform:rotate];
推荐答案
我不是100%但为什么你不使用 M_PI_2
。这只是简单的想法,你假设价值Pi
为 3.14
,但确切的值是 3.14159 ...
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...
我这样做,效果很好:
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 :
希望对您有所帮助。
这篇关于iOS - 尝试旋转文字标签,标签消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文