数字显示,添加数字滚动效果
MSNumberScrollAnimatedView
使用 MSNumberScrollAnimatedView 来显示数字时,可以添加数字滚动效果。
演示系统要求iOS7 及以上。
Automatic Reference Counting(ARC)
安装CocoaPods1. 在 Podfile 中添加 pod 'MSNumberScrollAnimatedView'。
2. 执行 pod install 或 pod update。
3. 导入头文件:#import <MSNumberScrollAnimatedView.h>。
1. 下载 MSNumberScrollAnimatedView 项目。
2. 将 MSNumberScrollAnimatedView 文件夹中的源文件拽入项目中。
3. 导入头文件:#import 'MSNumberScrollAnimatedView.h'。
你可以像使用普通视图一样来使用 MSNumberScrollAnimatedView
可以在xib中加载@property (nonatomic, weak) IBOutlet MSNumberScrollAnimatedView *numberAnimatedV; 也可以使用代码来创建MSNumberScrollAnimatedView *numberAnimatedV = [[MSNumberScrollAnimatedView alloc] initWithFrame:CGRectMake(0, 0, 320, 80)]; 提供这些属性来对动画进行定制// 样式相关 @property (nonatomic, strong) UIColor *textColor; @property (nonatomic, strong) UIFont *font; @property (nonatomic, assign) NSUInteger density; // 滚动数字的密度 @property (nonatomic, assign) NSUInteger minLength; // 最小显示长度,开题报告,不够补零 // 动画相关 @property (nonatomic, assign) NSTimeInterval duration; // 动画总持续时间 @property (nonatomic, assign) NSTimeInterval durationOffset; // 相邻两个数字动画持续时间间隔 @property (nonatomic, assign) BOOL isAscending; // 方向,默认为NO,向下 设置数字(最好是配置完样式属性后再 setNumber )self.numberAnimatedV.textColor = [UIColor redColor]; self.numberAnimatedV.font = [UIFont fontWithName:@'HelveticaNeue-Bold' size:42]; [self.numberAnimatedV setNumber:@1234]; 播放动画( setNumber 之后,播放动画才会有效 )[self.numberAnimatedV setNumber:@1234]; [self.numberAnimatedV startAnimation]; 刷新视图样式(如果在 setNumber 之后,修改了样式属性,开题报告,需要刷新视图才生效)[self.numberAnimatedV setNumber:@1234]; self.numberAnimatedV.textColor = [UIColor redColor]; [self.numberAnimatedV reloadView];github地址:
https://github.com/MrSongzj/MSNumberScrollAnimatedView