So I’m trying to set a UILabel, or a piece of mutable text really, so that it will move to different points on the screen at set intervals. I’m going to use a timer for the intervals but I don’t really have any idea how to move the label around. Looking for someone to point me in the right direction. All help is very much appreciated.
Share
Depends, do you want animation?
If you don’t want to animate the movement, it is as simple as changing its center point
If you wanted to animate the movement, it’s cake to add an animation block:
EDIT:
As of iOS 4, the recommended approach for animations are the block-based methods. For example:
transitionFromView:toView:duration:options:completion:andtransitionWithView:duration:options:animations:completion:These methods are only available in iOS 4+, so if you have a need to target anything earlier, you will have to use the other methods outlined in the UIView Class Reference.
Just from personal experience, using
blocksbased animations greatly simplifies your code, make it less spaghetti-like with all the delegate methods that would otherwise have to be implemented for callbacks, etc. Blocks are really, really powerful and are very much worth your time to use.