تأثير سرادق في uitableviewcells textlabel.text
-
05-07-2019 - |
سؤال
هل هناك وسيلة لتحقيق شيء مثل تأثير سرادق أتش تي أم أل لtextlabel.text uitableviewcells؟
المحلول
وسيكون لديك لتنفيذ ذلك بنفسك باستخدام 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;
}
لا تنتمي إلى StackOverflow