C# 页面滚动就像 iPhone 一样?
如何制作像 iPhone 菜单一样的水平滚动页面?它用于触摸屏应用程序,我想制作几个带有按钮的页面。
How do you make horizontal scrolling pages like the iPhone menu? It's for a touchscreen application and I want to make several pages with buttons.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有做过触摸,但一般来说,处理手指按下事件、手指移动事件和手指向上事件。
计算显示器上的速度(距离/时间——这可以用绝对距离单位或像素来完成)。在手指移动事件期间,按照距离增量滚动内容。在手指向上事件之后,快速降低计算的速度并继续使显示器沿着与手指向上事件之前相同的轴滚动。
为了获得更真实的效果,降级函数可能不是线性的。另外,计算速度可能应该有一个初始的一半,否则你将结束滚动菜单太远。尝试一下这些数字,你就会找到最佳点。
Have not done touch, but in general terms, handle finger down event, finger move event and finger up event.
Calculate the speed across the display (distance / time -- this can be done in absolute distance units or pixels). During the finger move event, scroll the contents in step with the distance delta. After the finger up event, quickly decrease the calculated speed and continue to cause the display to scroll along the same axis as before the finger up event.
The degredation function is probably not linear for more realistic effect. Also, there probably should be an initial half'ing of the calculated speed, otherwise you'll end of scrolling the menu too far. Play around with the numbers and you will find the sweet spot.
这不是一个 C# 问题,因为如果菜单和 UI 位于服务器上,那么它实际上与 JavaScript 和 HTML 更相关。滚动页面和 iPhone 菜单等是 UIKit 的副产品,UIKit 是表示层,类似于 HTML/JavaScript 是表示层解决方案。
我可能会从这个库开始,看看它是否适合您的需求: http://www.jqtouch.com/
This isn't a C# question as the menu and UI are really more related to JavaScript and HTML if this lives on a server. Scrolling pages and such like the iPhone menu are a byproduct of UIKit which is the presentation layer, similar to how HTML/JavaScript are presentation layer solutions.
I would probably start with this library and see if it suits your needs: http://www.jqtouch.com/