UILabel 与基于 Orientation 的 CGAffineTransformMakeRotation? (ARC、故事板、LLDB)
我以前曾问过这个问题一次,但关注度为 0,而且帮助我的人已经好几周没有回复了,所以请原谅我,但我仍然需要帮助。
我正在使用 CGAffineTransformMakeRotation 将 UILabel 翻转 180 度,我想要基于 UIOrientationPortrait 和 UIOrientationPortraitUpsideDown 的旋转。我得到 1/2 的结果:当用户翻转到上下颠倒(从纵向)时,标签会变换 180 并上下颠倒(仍然面向主页按钮 [重要]),
但是
当我将其旋转回纵向时,标签保持不变翻转旋转状态并且不停留在主页按钮上。这就是我需要的帮助......
这是我的代码:
#define degreesToRadian(x) (M_PI * (x) / 180.0)
...
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
}
I had asked this question once before but has had 0 attention and the person helping me has not responded in weeks, so please forgive me but I still do need help.
Im working with CGAffineTransformMakeRotation to flip a UILabel 180 degrees, I want the rotation based on UIOrientationPortrait and UIOrientationPortraitUpsideDown. I get 1/2 the result: when users flip to upside down (from portrait) the label transforms 180 and turns upside down as well (still facing the home button [Important])
BUT
when I rotate it back to Portrait the label stays in the flipped rotation state and does not stay with the home button. Thats what I need help with....
Here is the code i have:
#define degreesToRadian(x) (M_PI * (x) / 180.0)
...
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
TranslateLabel.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无论方向是什么,您都会将其颠倒旋转。如果您希望它根据方向以不同方式旋转,则必须执行以下操作:
这样,当设备颠倒时,它将上下旋转标签,而当设备处于纵向时,它将恢复正常方向。
You are rotating it upside down no matter what the orientation is. If you want it to rotate differently depending on the orientation, you have to do something like this:
That way, it will rotate the label upside down when the device is upside down and it will return it back to normal when the device is on portrait orientation.
我认为您想要打开
toInterfaceOrientation
,如果方向为UIInterfaceOrientationPortraitUpsideDown
则按照上面的方式设置变换,当方向为时设置为
。 (这假设您不允许旋转到其他方向。)CGAffineTransformIdentity
UIInterfaceOrientationPortraitI think you want to switch on
toInterfaceOrientation
, setting the transform as you have above if the orientation isUIInterfaceOrientationPortraitUpsideDown
and toCGAffineTransformIdentity
when it'sUIInterfaceOrientationPortrait
. (This assumes you don't allow rotations to the other orientations.)