我正在尝试使用动画在 Mac 应用程序中更改约束,NSAnimationContext runAnimationGroup...
但动画只有在我将其嵌入dispatch_after
块时才能正常工作。
结果我有这个代码:
__weak typeof(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf layoutSubtreeIfNeeded];
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
__strong typeof(weakSelf) strongSelf = weakSelf;
context.duration = animated ? 0.3 : 0.;
context.allowsImplicitAnimation = YES;
strongSelf.expanded = NO;
strongSelf.collapsingConstraint.priority = 900;
[strongSelf layoutSubtreeIfNeeded];
} completionHandler:^{
}];
});
我究竟做错了什么?提前致谢!