I have setup a view and I want to cycle the color of some text on that view using a timer. Is there a timer method for a view that gets called (or I can setup to get called) on a regular basis?
+1
A:
You could use an NSTimer with the following method:
timerWithTimeInterval:target:selector:userInfo:repeats:
Look here for further information:
schaechtele
2010-04-15 09:43:22
+1: create an NSTimer using `NSTimer *myTimer = [[NSTimer alloc] timerWithTimeInterval:<TIME> target:nil selector:@selector(<A_METHOD>:) userInfo:nil repeats:YES];` Then, in your `dealloc`, release it.
jrtc27
2010-04-15 10:22:53
So would I just add that timer to the view, set it up in viewDidLoad and then add a updateMyTextColor method?
fuzzygoat
2010-04-15 10:29:56
You can do so, if you know the time after which the event should fire in your viewDidLoad method.
schaechtele
2010-04-15 11:09:54
A:
NSTimer
will work for you as long as you don't require "fine" precision -- like sub-100ms.
Core Animation may work here as well. Are you animating a UILabel or are you rendering the text directly into the view with Core Graphics calls (or OpenGL)?
Shaggy Frog
2010-04-15 09:55:25