uitableviewcells textlabel.text中的选框效果

ver*_*ind 5 iphone uitableview

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

luv*_*ere 6

你必须使用NSTimer自己实现它.你可以textLabel.text通过从前面拿一个并将它附加到后面来循环你的角色.为了做到这一点很容易,你可以使用NSMutableString,你会操作使用substringWithRange: deleteCharactersInRange:appendString,然后设置为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;
}
Run Code Online (Sandbox Code Playgroud)

  • 这就像我搜索的第一个打击所以我想我会更新这个解决方案:https://github.com/cbpowell/MarqueeLabel非常容易使用并完成所有工作.很顺利.如果在表格视图中使用,请务必阅读我的评论:https://github.com/cbpowell/MarqueeLabel/issues/25 (2认同)