Tests已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
Released最后发布 | 2014 年 12 月 |
由 natanrolnik 维护。
NRTextTransitions 是 UIView 中的一个类别,使得对 UILabel、UITextView 和 UITextField 的动画文本过渡处理变得更加容易。由于标准的 +[UIView animateWithDuration:animations:]
无法动画非动画属性,包括 UILabel、UITextView 和 UITextField 的文字、字体和 textColor 属性,因此您需要使用 CATransition 来实现动画。
NRTextTransitions 使用与标准 UIView 类方法相似的 API,封装了动画参数块中传递的更改。为了将过渡应用于此块中提到的对象,您必须创建一个数组,将对象添加到该数组中,并将其作为 'textObjects' 参数传递。
exampleLabel.text = @"I'm the old text!";
exampleLabel.backgroundColor = [UIColor whiteColor];
[UIView animateTextTransitionForObjects:@[exampleLabel] withDuration:0.75 delay:0 animations:^{
exampleLabel.text = @"And I'm animated!";
} completion:^{
exampleLabel.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.5];
}];
您有两种选择
NRTextInstallation
UIView+NRTextTransitions.h/m
和 NRTextTransitionCompletionManager.h/m