WZTransitionLabel 是 UCLAiiLabel 的子类,当切换标签文本时提供了自定义过渡效果。
您可以通过在 pod spec 中添加 pod 'WZTransitionLabel'
来安装它,或者只需将 WZTransitionLabel.h
和 WZTransitionLabel.m
拖动到您的项目中。
WZTransitionLabel *label = [[WZTransitionLabel alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
label.attributedText = [[NSAttributedString alloc] initWithString:@"test string" attributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}];
NSAttributedString *toString = [[NSAttributedString alloc] initWithString:@"another string" attributes@{NSForegroundColorAttributeName:[UIColor redColor]}];
[label transiteToAttributedString:toString animated:YES duration:1.5];