有没有办法为uitableviewcells textlabel.text创建类似html Marquee效果的东西?
答案 0 :(得分: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;
}