项目问题集

这是一个实现UIScrollView中,某一栏内容自动弹到顶端的功能,用的是SpringPanel。

if (Input.GetKeyDown(KeyCode.A))
{
grid.Reposition();
scrollView.ResetPosition();
float y = NGUIMath.CalculateRelativeWidgetBounds(grid.transform).size.y;
print(y);
if (y <= 300)
{
scrollViewHeight.clipRange = new Vector4(0, -0.5fy, 302, y);
}
else
{
y = 300;
scrollViewHeight.clipRange = new Vector4(0, -0.5f
y, 302, y);
}
bg.height = (int)y + 100;
SpringPanel.Begin(sV, new Vector3(0, -50, 0), 60f);
scrollView.transform.localPosition = new Vector3(0,-50,0);
grid.transform.localPosition = new Vector3(0, 0, 0);

    }
    if (Input.GetKeyDown(KeyCode.S))
    {

        grid.Reposition();
        float y = NGUIMath.CalculateRelativeWidgetBounds(grid.transform).size.y;
        bg.height = (int)y + 100;
        scrollView.ResetPosition();
        
    }

    ![QQ截图20171124201256.png](http://upload-images.jianshu.io/upload_images/6288970-4cc1f3bb4ecce16b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
QQ截图20171124201311.png

你可能感兴趣的:(项目问题集)