随手记:
对于iOS文字动画,首先想到的应该是基于CoreText框架将文字每个都写出来,加上定时器给定每个字显示的时间,这是一种思维方式:
#import "ViewController.h"
#import <CoreText/CoreText.h>
@interface ViewController ()
{
NSMutableArray *labels;
NSMutableArray *numArr;
NSMutableArray *dataArr;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)buttonClick:(id)sender {
UIView *vi = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
vi.backgroundColor = [UIColor whiteColor];
[self.view addSubview:vi];
CATextLayer *textLayer = [CATextLayer layer];
textLayer.frame = vi.bounds;
textLayer.contentsScale = [UIScreen mainScreen].scale;
[vi.layer addSublayer:textLayer];
textLayer.alignmentMode = kCAAlignmentJustified;
textLayer.wrapped = YES;
UIFont *font = [UIFont fontWith