在iOS7中的scrollViewDidScroll方法中修改后NSLayoutConstraint未更新

在iOS7中的scrollViewDidScroll方法中修改后NSLayoutConstraint未更新,ios,ios7,autolayout,nslayoutconstraint,Ios,Ios7,Autolayout,Nslayoutconstraint,我有一个连接到情节提要的IBMOutlet NSLayoutConstraint属性: @property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleViewTopConstraint; 当滚动视图确实滚动时,我在scrollViewDidScroll方法中修改了此约束: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat yOffset

我有一个连接到情节提要的IBMOutlet NSLayoutConstraint属性:

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleViewTopConstraint;
当滚动视图确实滚动时,我在scrollViewDidScroll方法中修改了此约束:

- (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;
        }
}
-(无效)scrollViewDidScroll:(UIScrollView*)scrollView{
CGFloat yOffset=scrollView.contentOffset.y;

如果(yOffset您需要调用
layoutifneed
来更新视图的约束。所以一旦您更改了约束值,请在下面的行中进行拍摄

[self.view layoutIfNeeded];

您需要调用
layoutifneed
来更新视图的约束。所以,一旦更改了约束值,请在下面的行中进行拍摄

[self.view layoutIfNeeded];