使用的是AutoLayout,想实现一个在窗口内移动一个view的动画效果。本来是一个居中对齐的constraint(优先级1),然后再手动加一个顶部50px的constraint(优先级2)
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
context.duration = 5.0f;
NSDictionary *viewsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:self.warningView, @"warningView", nil];
NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-50@2-[warningView]" options:0 metrics:nil views:viewsDictionary];
[[self.contentView animator] addConstraints:constraints];
} completionHandler:^{
NSLog(@"%@", [self.warningView constraintsAffectingLayoutForOrientation:NSLayoutConstraintOrientationVertical]);
}];
照理应该是运动五秒后再执行completionHandler,但是程序直接跳过了动画部分,直接设定了constraint,然后运行了completionHandler,非常奇怪。
认证0级讲师