Ronald Hofmann
Ronald Hofmann

Reputation: 1430

Is it possible to animate a NSTextField

I´m trying a pretty simple thing for testing and can´t get it to work, sorry.
What I want to achieve is that the changes in the textfield label are seen on the screen as well as the color changes.

I already tried several things without success and I´m pretty sure I haven´t got the clue yet.

Any ideas what I´m doing wrong?

I have this right now:

- (IBAction) writeTextToLabel:(id)sender
{

   NSAnimation *animation;

   [animation setDuration:10];

   int n = 100;

   NSString *string1 = @"";

   [animation startAnimation];

   for (int i = 1 ; n >= i ; i++) {

      [label setTextColor:[self ccRandom:1.0 :0.0]];
      string1 = [NSString stringWithFormat:@"Hello World %.3i\n",i];
      [label setStringValue:string1];

   }

   [animation stopAnimation];

}

Upvotes: 1

Views: 1223

Answers (1)

goooseman
goooseman

Reputation: 619

You can use AnimTextFieldUsingNSAnimationContext by ipmcc This code makes fadeIn/fadeOut effect of changing text. But you can add changing color code after [self setStringValue: aString]; to change your color. Don't forget to include Quartz.framework to your project.

Upvotes: 2

Related Questions