Touch and pull down a view

后端 未结 3 2011
终归单人心
终归单人心 2020-12-28 11:16

I have a uiview at the top of the interface (below the status bar) that only the bottom part of it is shown.

Actually, I want to make the red uiview to slide down

3条回答
  •  鱼传尺愫
    2020-12-28 11:32

    Make a subclass of UIView.

    Override touchesBegan:withEvent and touchesMoved:withEvent.

    In the touchesBegan perhaps make a visual change so the user knows they are touching the view. In the touchesMoved use [[touches anyObject] locationInView:self] and [[touches anyObject] previousLocationInView:self]

    to calculate the difference between the current touch position and the last touch position (detect drag down or drag back up).

    Then if you're custom drawing, call [self setNeedsDisplay] to tell your view to redraw in it's drawRect:(CGRect)rect method.

    Note: this assumes multiple touch is not used by this view.

提交回复
热议问题