I'm trying to animate constraints change in Mac app using NSAnimationContext runAnimationGroup...
but animation works fine only if I embed it inside dispatch_after
block.
In result I have this code:
__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:^{
}];
});
What am I doing wrong? Thanks in advance!