iOS 模仿抖音的加载动画

#import "masonry.h"

@interface ViewController ()
{
    UIView *line;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    line = [UIView new];
    line.backgroundColor = [UIColor redColor];
    [self.view addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.centerX.equalTo(line.superview);
        make.width.mas_equalTo(80);
        make.top.mas_equalTo(100);
    }];
    
    [self performSelector:@selector(addAnimation) withObject:nil afterDelay:0];
}

-(void)addAnimation {
    const CGFloat animationDuration = 0.4; //动画时间
    const CGFloat lineOriginWidth = 80; //进度条的开始宽度
    const CGFloat lineResultWidth = 350; //进度条的结束宽度
    const CGFloat times = (lineResultWidth - lineOriginWidth)/lineOriginWidth; //倍数
    const int count = 6; //数组的个数
    
    NSMutableArray *values = [NSMutableArray array];
    for (int i=0; i

做得不好,仅供参考。

你可能感兴趣的:(iOS 模仿抖音的加载动画)