当UIScrollView向上滚动时移动UIView

时间:2015-12-30 19:44:35

标签: ios uitableview uiview uiscrollview masonry

我正在尝试完成与此类似的事情:Move a view when scrolling in UITableView但我想在后台移动其中一个视图(并非所有视图)。这是我到目前为止所做的(我使用Masonry作为autoLayout):

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    //There is an array of views, which I want to move when scrolling

    for (UIView *view in self.movedViews) {


        CGFloat offset = scrollView.contentOffset.y;

    //Here I get the default Y origin of the view, so I can move them equally

        originY = view.frame.origin.y;
        CGFloat diff = (scrollView.contentInset.top)-originY;

        [view mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(view.superview.mas_top).with.offset((-offset)-diff);
        }];
    }

}

问题是我无法在view.frame.origin.y之后使用mas_updateConstraints进行更改$("#body").val("testing123"); var i = 0; while (i <= 5) { var value = 20; function result(a) { var x = document.getElementsByClassName(a); return x[0].innerHTML; } y = result('val'); setTimeout(function() { document.getElementById('val').value =value; setTimeout(function() { document.getElementById('play').click(); setTimeout(function() { y = result('val'); if(y == "LOSE") { bet = value*2; document.getElementById('val').value =value; i++; } else if(y == "WIN") { value = 20; document.getElementById('val').value =value; i = 5; } else { document.getElementById('val').value ='ERROR'; value = 0; i = 5; } }, 2000); }, 2000); }, 7000); } 。此外,我想让视图在向上滚动时移动。我愿意接受任何不同的解决方案。谢谢你们!

0 个答案:

没有答案