2 つの同時移動アニメーションを実行したい。最初のアニメーションfirstViewがすぐに開始されます。の2 番目のアニメーションsecondViewは、最初のアニメーションがまだ実行されている間に少し遅れて開始されます。secondView制約は に関連していfirstViewます。コードは iOS 8 で完全に機能します。
firstViewとsecondViewのサブビューですview
view
|--- firstView
|--- secondView
コード:
UIView *firstView = ...;
UIView *secondView = ...;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:firstView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:constraint];
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
}];
[UIView animateWithDuration:0.5 delay:0.15 options:UIViewAnimationOptionCurveEaseInOut animations:^{
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:secondView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:firstView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:constraint];
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
}];
iOS 7 では、秒layoutIfNeededが呼び出されると、最初のアニメーションが停止し、秒のアニメーションのみがアニメーション化されます。
助言がありますか?