Ngui 左右滑动
2016-03-16 15:12
169 查看
实现效果图:
private UIScrollView fubenScrollView; private UIGrid fubenGrid; public void OnBtnRight()//右btn { if (fubenScrollView == null || fubenGrid == null) return; int curIndex = GetFubenScrollViewIndex(); Vector3 targetPos = new Vector3(-(curIndex + 1) * fubenGrid.cellWidth, fubenScrollView.transform.localPosition.y, 0); CapterData chapterData; if (CapterManager.Instance.getCapterDataById(currentChapterId.ToString(), out chapterData)) { List<int> fubenIds = chapterData.Commonfubens; if (targetPos.x < - ((fubenIds.Count - 4) * fubenGrid.cellWidth + 10)) { return; } } SpringPanel.Begin(fubenScrollView.panel.cachedGameObject, targetPos, 6f); } public void OnBtnLeft()//左btn { if (fubenScrollView == null || fubenGrid == null) return; int curIndex = GetFubenScrollViewIndex(); Vector3 targetPos = new Vector3(-(curIndex - 1) * fubenGrid.cellWidth, fubenScrollView.transform.localPosition.y, 0); if (targetPos.x > 10) { return; } SpringPanel.Begin(fubenScrollView.panel.cachedGameObject, targetPos, 6f); } private int GetFubenScrollViewIndex() { if (fubenScrollView == null || fubenGrid == null) return 0; return Mathf.Abs(Mathf.RoundToInt(fubenScrollView.transform.localPosition.x / fubenGrid.cellWidth)); }
相关文章推荐
- 解决的方法:warning: Clock skew detected. Your build may be incomplete.
- Xcode中的Version和Build的区别
- 导航栏颜色及UIBarButtonItem 的设置
- iOS This certificate has an invalid issuer
- 给UI控件画边框
- 从keyPressEvent按键事件中获取QKeySequence
- iOS开发中使用UIScrollView实现无限循环的图片浏览器
- mysql中key 、primary key 、unique key 与index区别
- UITableViewCell滑动删除及移动
- Swfit UITableView的使用(六)
- UICollectionView Section 纯代码代码控制 HeaderView和FooterView的显示,uicollectionview
- StringBuilder和String的区别
- Activity.runOnUiThread(Runnable)简单介绍
- uva 11195 Another queen (用状态压缩解决N后问题)
- php中使用$_REQUEST需要注意的一个问题
- Django View Request和Response
- iOS之UIScrollview添加约束图文详解
- 225. Implement Stack using Queues
- cocoa touch框架UIkit学习
- iOS SDK蓝牙4.0相关的组件为CoreBluetooth,官方文档翻译