'drag' move a uibutton so it acts like uiS

2019-03-02 00:08发布

I need to slide a uibutton up and down the screen (Y only). It needs to be confined to an area. I want to be able to click on it and drag or flick it, just like a uiScrollView. The reason it is different to a uiScrollView is that you have to start on the button, as opposed to anywhere inside a uiScrollView!

1条回答
叼着烟拽天下
2楼-- · 2019-03-02 00:36

You can move a view by using touch moved event. There is a sample tutorial MoveMe by Apple which drags a view and after releasing the touch animate the view. Check specially the touch events (touchesBegan, touchesMoved, touchesEnded) in MoveMeView.m to get the idea how they have moved placardView. You can move your button just like the placardView.

查看更多
登录 后发表回答