Effet de sélection dans uitableviewcells textlabel.text
-
05-07-2019 - |
Question
Existe-t-il un moyen d’accomplir quelque chose comme l’effet Marquee html pour un textlabel.text uitableviewcells?
La solution
Vous devrez l'implémenter vous-même à l'aide d'un NSTimer. Vous parcourez les caractères de votre textLabel.text
en les prenant de l'avant et en les ajoutant à l'arrière. Pour ce faire facilement, vous pouvez utiliser un NSMutableString
que vous manipuleriez avec substringWithRange:
deleteCharactersInRange:
et appendString
. , puis défini comme textLabel.text
après chaque manipulation de caractère:
- (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;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow