簡體   English   中英

uitableviewcells中的字幕效果textlabel.text

[英]marquee effect in uitableviewcells textlabel.text

有沒有辦法為uitableviewcells textlabel.text完成類似html Marquee效果的方法?

您必須使用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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM