CAAnimateLabel 1.4.0

CAAnimateLabel 1.4.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年5月

ChenAo 维护。



一个标签可以动画和快速自定义动画

特性

  • 提供一些动画属性(持续时间、延迟、重复次数等)
  • 提供标签属性,如文本对齐、行间距、字体、颜色、布局类型
  • 支持 NSAttributedString 显示
  • 通过 CAAnimateLabelDelegate 自定义和检测动画

缩放

image

下落

image

飞行

image

透明度

image

弹簧

image

虚线

image

旋转

image

揭示

image

扔掷

image

自定义绘制动画

image

自定义图层动画

image

安装

使用方法

    self.animateLabel = [CAAnimateLabel new];
    self.animateLabel.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    [self.view insertSubview:self.animateLabel atIndex:0];
    self.animateLabel.type = self.animateType;
    
    self.animateLabel.layoutType = CATextLayoutSentenceType;
    self.animateLabel.lineSpacing = 10;
    self.animateLabel.textColor = [UIColor greenColor];
    self.animateLabel.textAlignment = CATextAlignmentCenter;
    self.animateLabel.font = [UIFont systemFontOfSize:18.0];
    self.animateLabel.duration = 3.0;
    self.animateLabel.delay = 0.5;
    self.animateLabel.repeatCount = 2;
    self.animateLabel.text = @"青春,是人生中最美的风景。\n青春,是一场花开的遇见;\n青春,是一场痛并快乐着的旅行;\n青春,是一场轰轰烈烈的比赛;\n青春,是一场鲜衣奴马的争荣岁月;\n青春,是一场风花雪月的光阴。";
    self.animateLabel.contentInsets = UIEdgeInsetsMake(100, 10, 10, 10);
    if (self.animateType == CAAnimateLabelCustomType) {
        self.animateLabel.layerAnimate = YES;
        self.animateLabel.delegate = self;
        self.animateLabel.restore = NO;
    }

协议一致性

遵守 CAAnimateLabelDelegate。

@interface ViewController ()<CAAnimateLabelDelegate>
@property (nonatomic, strong) CAAnimateLabel *label;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.label.delegate = self;
}

实现

- (void)animationWillStartTextAttribute:(CATextAttribute *)textAttribute forIndex:(NSInteger)index {
	//call animation start
}

- (void)animationDidEndTextAttribute:(CATextAttribute *)textAttribute forIndex:(NSInteger)index {
	//call aniamtion end
}

- (void)prepareLayerByTextAttribute:(CATextAttribute *)textAttribute forIndex:(NSInteger)index {
  //call when layerAnimate is YES prepare layer animation
}

- (CGRect)animationDrawRectForTextAttribute:(CATextAttribute *)textAttribute forIndex:(NSInteger)index {
    // Reture draw animation rect
    return textAttribute.rect;
}

- (void)animationAtRect:(CGRect)rect ForTextAttribute:(CATextAttribute *)textAttribute forIndex:(NSInteger)index {
   //custom layer or draw aniamtion 
    
}

许可证

MIT 许可证

版权所有 (c) 2017 ChenAo

以下是对任何人获取本软件及其相关文档文件(以下简称“软件”)副本的许可,无需支付费用。允许在不限制的情况下处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向其提供软件的人进行上述操作,但须遵守以下条件。

上述版权声明和本许可声明应包含在软件的任何副本或实质部分中。

软件按“原样”提供,不提供任何形式的质量保证,无论是明示的、暗示的,包括但不限于对适销性、适用于特定目的和非侵权的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论是否为合同行为、侵权或任何其他行为,与软件或软件的使用或其他使用有关。