菜鸟教程小白 发表于 2022-12-11 20:18:35

ios - 与 iOS 10+ 类似设计的滑动删除 UITableViewCell 中的通知滑动删除


                                            <p><p>如何使要删除的 tableviewcell 幻灯片看起来像要删除 iOS 通知的幻灯片(淡入并且不要触摸屏幕边缘)。我将只有删除按钮,所以我不需要多个按钮。我希望它像通知一样在完全滑动时删除。 </p>

<p>这是一张带有 2 个按钮的想要结果的照片(我只想要 1 个):</p>

<p> <a href="/image/hfCXJ.jpg" rel="noreferrer noopener nofollow"><img src="/image/hfCXJ.jpg" alt="iOS notification swipe to delete"/></a> </p>

<p>我写的当前代码只是将编辑样式设置为删除。我曾尝试使用 <code>UIContextualAction</code> 但我相信我只能设置样式、背景颜色和/或图像。</p>

<pre><code>func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -&gt; Bool {
    return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
      print(&#34;delete&#34;)
    }
}
</code></pre>

<p>这是我当前代码的样子:<a href="/image/HAqws.jpg" rel="noreferrer noopener nofollow"><img src="/image/HAqws.jpg" alt="What I currently have"/></a> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>尝试在 <code>UITableViewCell</code> 内添加一个 UIView,带有红色背景,并在 <code>UIView</code> 内添加一个带有删除文本的标签。祝你好运!</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 与 iOS 10&#43; 类似设计的滑动删除 UITableViewCell 中的通知滑动删除,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/51120827/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/51120827/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 与 iOS 10&#43; 类似设计的滑动删除 UITableViewCell 中的通知滑动删除