0
votes

I have an IBOutlet NSLayoutConstraint property connected to storyboard:

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleViewTopConstraint;

When the scroll view did scroll, I modify this constraint in scrollViewDidScroll method:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        CGFloat yOffset  = scrollView.contentOffset.y;

        if (yOffset <= -20) {
            [self.logoView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(@(yOffset));
                    make.height.equalTo(@(fabs(yOffset) + self.ImageHeight + STATUSBAR_HEIGHT))}];

         }

        CGFloat top = self.ImageHeight - self.titleView.height - yOffset - 20;
        self.titleViewTopConstraint.constant = top;
        if (self.titleViewTopConstraint.constant < 25) {
            self.titleViewTopConstraint.constant = 25;
        }
}

I'm trying to update the constant when scroll view did scroll and it works fine in iOS8. But the constant doesn't seem to update after setting in iOS7 .

Any idea what can cause this problem and how can i solve it? Thanks.

1

1 Answers

2
votes

You need to call layoutIfNeeded to update constraint of view. So once you change your constraint value shoot below line.

[self.view layoutIfNeeded];