简体   繁体   English

如何在iPhone中使用getControlPointAtIndex函数旋转半圆UILabel

[英]How to use getControlPointAtIndex function to rotate a UILabel in semicircle in iPhone

I want to rotate a UILabel in semicircle. 我想半圆旋转UILabel。

So what I am planning to do is use some timing function like CaMediaTimingFunction. 所以我打算做的是使用一些定时功能,例如CaMediaTimingFunction。

I want to use getControlPointAtIndex method of CaMediaTiming Function so that I can get a set of points to rotate the UILabel. 我想使用CaMediaTiming函数的getControlPointAtIndex方法,以便获得一组旋转UILabel的点。 The points which I will get will help me in forming the frame for UILabel. 我将获得的要点将帮助我形成UILabel的框架。

Does anybody have good idea other than this. 除此以外,还有其他人有什么好主意吗?

I want to rotate the Label in a semicircle very smoothly. 我想非常平滑地旋转Label的半圆。

If all you want to do is rotate the label in an animated fashion, you should just be able to set the transform property of the UILabel within an animation block, like the following: 如果您要做的只是以动画方式旋转标签,则应该只可以在动画块内设置UILabel的transform属性,如下所示:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5.0f];

label.transform = CGAffineTransformMakeRotation(90.0f * M_PI / 180.0f);

[UIView commitAnimations];

This will rotate your label by 90 degrees over a duration of 5 seconds. 这将在5秒钟的时间内将标签旋转90度。

If you wish to control the clockwise / counterclockwise direction of the rotation, you can refer to this answer , which shows how to use lower-level Core Animation keyframe animations to do this. 如果要控制旋转的顺时针/逆时针方向,可以参考此答案该答案显示了如何使用较低级别的Core Animation关键帧动画来执行此操作。

If you're making a game, you might want to take a look at cocos2d - it has some simple rotation & timer actions that are pretty easy to use. 如果您正在制作游戏,则可能需要看一下cocos2d-它具有一些简单的旋转和计时器操作,非常易于使用。

http://code.google.com/p/cocos2d-iphone/ http://code.google.com/p/cocos2d-iphone/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM