Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

marquee effect in uitableviewcells textlabel.text

Is there a way to accomplish something like the html Marquee effect for a uitableviewcells textlabel.text?

like image 853
versatilemind Avatar asked Nov 27 '09 12:11

versatilemind


1 Answers

You'll have to implement it yourself using a NSTimer. You would cycle trough the characters of your textLabel.text by taking one from the front and appending it to the back. In order to do this easily you could use a NSMutableString that you would manipulate using substringWithRange: deleteCharactersInRange: and appendString, and then set as textLabel.text after each character manipulation:

- (void)fireTimer
{
  NSMutableString *mutableText = [NSMutableString stringWithString: textLabel.text];
  //Takes the first character and saves it into a string
  NSString *firstCharText = [mutableText substringWithRange: NSMakeRange(0, 1)];
  //Removes the first character
  [mutableText deleteCharactersInRange: NSMakeRange(0, 1)];
  //Adds the first character string to the initial string
  [mutableText appendString: firstCharText];

  textLabel.text = mutableText;
}
like image 71
luvieere Avatar answered Nov 15 '22 04:11

luvieere