The proper way of doing chain animations

前端 未结 5 1789
余生分开走
余生分开走 2020-12-10 09:14
void (^first_animation)();
void (^second_animation)(BOOL finished);


// First animation

first_animation = ^()
{
    g_pin_info_screen.view.alpha = 1.0;
};


// Sec         


        
5条回答
  •  我在风中等你
    2020-12-10 10:05

    Just check here: https://gist.github.com/vadimsmirnovnsk/bce345ab81a1cea25a38

    You can chain it in functional style:

    dispatch_block_t animationsBlock = ^{
        [self.view updateConstraintsIfNeeded];
        [self.view layoutIfNeeded];
    };
    
    [[[[[[[[[BARAnimation construct]
        initially:animationsBlock]
        animationWithDuration:0.425 animationConditions:^{
            [gridView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(imageView).with.offset(32.0);
            }];
        } animations:animationsBlock]
        animationWithDuration:0.425 animationConditions:^{
            [gridView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(imageView).with.offset(0.0);
            }];
        } animations:animationsBlock]
        animationWithDuration:0.425 animationConditions:^{
            [gridView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(imageView).with.offset(-32.0);
            }];
        } animations:animationsBlock]
        animationWithDuration:0.425 animationConditions:^{
            [gridView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(imageView).with.offset(0.0);
            }];
        } animations:animationsBlock]
        animationWithDuration:0.8 animationConditions:nil animations:^{
            foreView.alpha = 1.0;
        }]
        finally:^{
            [self.didEndSubject sendNext:[RACUnit defaultUnit]];
            [self.didEndSubject sendCompleted];
        }]
        run];
    

提交回复
热议问题