如何使用ZCAnimatedLabel为标签文本设置动画?

时间:2017-02-08 15:56:17

标签: ios objective-c

ZCAnimatedLabel扩展了UIView,因为UILabel类无法重命名为ZCAnimatedLabel。使用ZCAnimatedLabel为标签文本设置动画的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

如果您对CocoaPods Libraries有疑问而不是第一次结账,那么git repo将了解如何使用它。 ZCAnimatedLabel

试试这个:

ZCAnimatedLabel *label;
label.animationDuration = 1;
label.animationDelay = 1;
label.text = @"AnimateLabel";
// add animation type
object_setClass(label, [ZCAnimatedLabel class]);
// start Animation
[label startAppearAnimation];

停止动画:

[self.label startDisappearAnimation];

您可以添加到标签的不同类型的动画:

//Throw
object_setClass(label, [ZCThrownLabel class]);
//Shapeshift
object_setClass(label, [ZCShapeshiftLabel class]);
//Default
object_setClass(label, [ZCAnimatedLabel class]);
//Duang
object_setClass(label, [ZCDuangLabel class]);
//Fall
object_setClass(label, [ZCFallLabel class]);
//Alpha
object_setClass(label, [ZCTransparencyLabel class]);
//Flyin
object_setClass(label, [ZCFlyinLabel class]);
//Blur
object_setClass(label, [ZCFocusLabel class]);
//Reveal
object_setClass(label, [ZCRevealLabel class]);
//Spin
object_setClass(label, [ZCSpinLabel class]);
label.layerBased = YES;
//Dash
object_setClass(label, [ZCDashLabel class]);
label.layerBased = YES;