OS X Masonry view animation without effect

144 Views Asked by At

[macOS | OS X] Masonry view animation without effect

  • [✔️] I have looked at the Documentation
  • [✔️] I have filled out this issue template.

Issue Info

  • Platform: os x
  • Platform Version: 10.12.6
  • Masonry Version: 1.1.0

Issue Description

I'm using masonry autolayout in os x application project, I find out move animation in the view without effect. That is to say the view direct move to target location and no animation process.

My code is as follows:

[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
    [context setDuration:0.5];
    context.allowsImplicitAnimation = YES;
    [_playlistView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_right).with.offset(-kPlaylistBuoyBtnW-kPlaylistMainViewW);
    }];
} completionHandler:^{
    debugMethod();
}];

How to implement? It is best to use the sample code.

Appreciate if any suggestion or idea.

1

There are 1 best solutions below

0
On

First, declare an property in the view's interface.

@property (nonatomic, strong) MASConstraint *leftConstraint;

Secondly, use this property to do animation.

[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
    [context setDuration:kPlaylistPopAnimationTimes];
    context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    _playlistView.leftConstraint.animator.offset(-kPlaylistBuoyBtnW-kPlaylistMainViewW);
} completionHandler:^{
    [_playlistView updateBuoyBtnState:state];
}];

Finally, other direction of animation is the same.