Jaime Shawn
Jaime Shawn

Reputation: 33

OS X Masonry view animation without effect

[macOS | OS X] Masonry view animation without effect

Issue Info

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.

Upvotes: 0

Views: 138

Answers (1)

Jaime Shawn
Jaime Shawn

Reputation: 33

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.

Upvotes: 0

Related Questions