Ios UIView将具有不同持续时间的动画组合在一起

Ios UIView将具有不同持续时间的动画组合在一起,ios,objective-c,animation,uiview,uiviewanimation,Ios,Objective C,Animation,Uiview,Uiviewanimation,我想在视图上设置alpha更改和帧更改的动画。关键是我希望alpha更改在帧更改之前结束。 目前,我正在做类似的事情,以同时实现这两个目标: UIView *someview = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; [self.view addSubview:someview]; someview.alpha = 0.0f; [UIView animateWi

我想在视图上设置alpha更改和帧更改的动画。关键是我希望alpha更改在帧更改之前结束。 目前,我正在做类似的事情,以同时实现这两个目标:

UIView *someview = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
        [self.view addSubview:someview];
        someview.alpha = 0.0f;
        [UIView animateWithDuration:1 animations:^{
            self.view.alpha = 1.0f;
            self.view.frame = CGRectMake(200, 200, 100, 100);
        }];

如果要在动画之后执行任何更改,则应使用完成处理程序设置持续时间的动画

[UIView animateWithDuration:1 animations:^{
        self.view.alpha = 1.0f;
        self.view.frame = CGRectMake(200, 200, 100, 100);
    }];
用下面给出的代码替换上面的代码

[UIView animateWithDuration:1.0 animations:^{
    self.view.alpha = 1.0f;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:1 animations:^{
        self.view.frame = CGRectMake(200, 200, 100, 100);
    }];
}];

在该块中,第一个alpha动画发生,当完成帧动画时,将发生

我认为您应该替换此:

[UIView animateWithDuration:1 animations:^{
    self.view.alpha = 1.0f;
    self.view.frame = CGRectMake(200, 200, 100, 100);
}];
致:


可以通过使用两个具有不同持续时间的不同动画来实现这一点。
[UIView animateWithDuration:1 animations:^{
    self.view.alpha = 1.0f;
}];
[UIView animateWithDuration:1.4 animations:^{
    self.view.frame = CGRectMake(200, 200, 100, 100);
}];