有没有办法为uitableviewcells textlabel.text创建类似html Marquee效果的东西?

有帮助吗?

解决方案

您必须使用NSTimer自行实施。您可以通过从前面取一个并将其附加到后面来循环遍历 textLabel.text 的字符。为了轻松地执行此操作,您可以使用 substringWithRange: deleteCharactersInRange: appendString 操作的 NSMutableString ,然后在每个字符操作后设置为 textLabel.text

- (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;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top