类似于 UILabel 的视图,具有易于扩展的显示/隐藏动画
ZCAnimatedLabel
通过 CocoaPods 提供。如果你不需要所有的效果子类,只需将 ZCAnimatedLabel.(h|m)
,ZCCoreTextLayout.(h|m)
和 ZCEasingUtil.(h|m)
拖入你的项目中,并开始自定义。
ZCAnimatedLabel
有两种模式:非层和基于层。在第一种模式中,ZCAnimatedLabel
是一个平面的 UIView
,每个动画阶段都是使用 Core Graphics 绘制的,你可以自定义重绘区域以获得更佳的性能。以下方法可以被覆盖:
- (void) textBlockAttributesInit: (ZCTextBlock *) textBlock;
- (void) appearStateDrawingForRect: (CGRect) rect textBlock: (ZCTextBlock *) textBlock;
- (void) disappearStateDrawingForRect: (CGRect) rect textBlock: (ZCTextBlock *) textBlock;
- (CGRect) redrawAreaForRect: (CGRect) rect textBlock: (ZCTextBlock *) textBlock;
第二种选项是基于层,其中每个文本块都是一个简单的 CALayer
,通过设置层的 transform
属性,可以在这种模式中实现 3D 转换,如果在重绘区域大且文本块不多的情况下,可以实现性能提升。设置 self.layerBased
为 YES
并覆盖以下方法进行自定义:
- (void) textBlockAttributesInit: (ZCTextBlock *) textBlock;
- (void) appearStateLayerChangesForTextBlock: (ZCTextBlock *) textBlock;
- (void) disappearLayerStateChangesForTextBlock: (ZCTextBlock *) textBlock;
LTMorhpingLabel
提供了重要的灵感。如果你喜欢 ZCAnimatedLabel
,你绝对应该试试这个。ZCDashLabel
中使用的任意形状 3D 变换代码片段。