Quantcast
Channel: How do I animate constraint changes? - Stack Overflow
Viewing all articles
Browse latest Browse all 13

Answer by D.D. for How do I animate constraint changes?

$
0
0

There is an article talk about this:http://weblog.invasivecode.com/post/42362079291/auto-layout-and-core-animation-auto-layout-was

In which, he coded like this:

- (void)handleTapFrom:(UIGestureRecognizer *)gesture {    if (_isVisible) {        _isVisible = NO;        self.topConstraint.constant = -44.;    // 1        [self.navbar setNeedsUpdateConstraints];  // 2        [UIView animateWithDuration:.3 animations:^{            [self.navbar layoutIfNeeded]; // 3        }];    } else {        _isVisible = YES;        self.topConstraint.constant = 0.;        [self.navbar setNeedsUpdateConstraints];        [UIView animateWithDuration:.3 animations:^{            [self.navbar layoutIfNeeded];        }];    }}

Hope it helps.


Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>