Making a pull out tray - (iOS)

北城以北 提交于 2019-12-11 18:42:31

问题


I'm making an iPad app, and basically, I want to make a tray that pulls out from the bottom of my app, and I'd like to have a little tab at the bottom of the screen that if you pull, it brings up an image, and the image's height would match the height you pulled the button to. It's a bit like how the notification center works, except the tab is always visible.

So my question is how would I have the image follow the tab as it moves vertically across the screen? I would assume using a UIButton for the tab and a UIImage for the tray would make sense, and I have some code for making buttons move, but how can you make one object follow another?

Thanks for your help, -Karl


回答1:


I wouldn't use a button for the tab -- just a regular old view.

To make your image follow the tab (however you implement either of them), simply animate them both together. That is, if you create an animation that moves the center of the button to the Y-coordinate of the user's touch, you can at the same time move the image vertically by the same amount. The two objects will then seem glued together because they move together.



来源:https://stackoverflow.com/questions/11531373/making-a-pull-out-tray-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!