NSLayoutConstraint.constant ignoring animation

前端 未结 4 719
情歌与酒
情歌与酒 2021-01-31 11:09

I\'m creating an autolayout-friendly split view class for one of my applications. Among its various features is that it can collapse panes, and can animate their collapse, much

4条回答
  •  情话喂你
    2021-01-31 11:52

    I agree, this is pretty strange, and could well be a bug. I'd definitely report it as such because, to the best of my knowledge, this should work.

    I was able to get it to work by using the NSAnimationContext class method +runAnimationGroup:completionHandler: instead of the beginGrouping and endGrouping statements:

    [NSAnimationContext runAnimationGroup:^(NSAnimationContext* context){
        [constraint.animator setConstant:self.width];   
    } completionHandler:^(void){
        [theView removeConstraint:constraint];
        NSLog(@"completed");
    }];
    

提交回复
热议问题