菜鸟教程小白 发表于 2022-12-12 16:08:11

ios - 用手指向上拖动 subview Controller 并锁定在点之后


                                            <p><p>我正在尝试实现两个 ViewController 之间的平滑过渡。我想要做的是在 VC 1 的底部有一个 UIView。当用户向上滑动/拖动 View 时,将以模态方式呈现 VC 2。我想要发生的是当用户向上拖动 View 时, View 将跟随手指,VC 2 将被拖动到屏幕上。一旦用户的手指越过一个点然后被释放,我希望它能够锁定到位。</p>

<p>当用户在 View 上向上滑动时,我已经成功实现了 UIGestureRecognizer。然后呈现。这样做只有两个问题:</p>

<p>1) 它不会随着用户的手指过渡
2) 只有 4 种模态过渡样式(Cover Vertical、Flip Horizo​​ntal、Cross Dissolve 和 Partial Curl)——我都不想使用。我想让它向上滑动。</p>

<p>我研究并发现了这个问题<a href="https://stackoverflow.com/questions/17162849/how-to-swipe-down-a-uiviewcontroller-from-another" rel="noreferrer noopener nofollow">How to swipe down a UIViewController from another</a>但是它没有帮助,因为它呈现的是 UIView 而不是 UIViewController!</p>

<p>如果有人有任何建议或示例代码来自以前做过这件事的人,那就太好了! </p>

<p>谢谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你可以使用<code>UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate</code> 来做你想做的动画,这些链接可以是很好的起点<a href="http://www.doubleencore.com/2013/09/ios-7-custom-transitions/" rel="noreferrer noopener nofollow">ios 7 custom transition</a>
和 <a href="http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/" rel="noreferrer noopener nofollow">Custom UIViewController Transitions</a>并观看 WWDC 2013 session 218 video <code>Custom Transitions Using View Controllers</code></p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 用手指向上拖动 subviewController 并锁定在点之后,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/19739045/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/19739045/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 用手指向上拖动 subview Controller 并锁定在点之后