开发者

marquee effect in uitableviewcells textlabel.text

开发者 https://www.devze.com 2022-12-13 03:44 出处:网络
Is开发者_如何学Go there a way to accomplish something like the html Marquee effect for a uitableviewcells textlabel.text? You\'ll have to implement it yourself using a NSTimer. You would cycle trough

Is开发者_如何学Go there a way to accomplish something like the html Marquee effect for a uitableviewcells textlabel.text?


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消