efecto de marquesina en uitableviewcells textlabel.text
-
05-07-2019 - |
Pregunta
¿Hay alguna manera de lograr algo como el efecto Marquee html para un uitableviewcells textlabel.text?
Solución
Tendrá que implementarlo usted mismo utilizando un NSTimer. Usted pasaría por los caracteres de su textLabel.text
tomando uno del frente y agregándolo al dorso. Para hacer esto fácilmente, puede usar un NSMutableString
que manipularía utilizando substringWithRange:
deleteCharactersInRange:
y appendString
y, a continuación, establezca como textLabel.text
después de cada manipulación de caracteres:
- (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;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow