ios - 设置 UIContextualAction 大小
<p><p>我想知道是否可以设置 <code>UIContextualAction</code> 大小(宽度和高度)。</p>
<p>我在 <code>UIContextualAction</code> 中没有找到任何允许我这样做的成员,所以我想知道是否有一个解决方法可以做到这一点?</p>
<pre><code>action.image = UIGraphicsImageRenderer(size:CGSize(width: 35, height: 35)).image { _ in
UIImage(named:"Delete")?.draw(in: CGRect(x:0, y: 0, width: 35, height: 35))
}
action.backgroundColor = UIColor.red
return action
</code></pre>
<p> <a href="/image/mOLns.png" rel="noreferrer noopener nofollow"><img src="/image/mOLns.png" alt="result"/></a> </p>
<h2>更新</h2>
<p>我找到了这篇文章,背后的想法是使用自定义按钮并使用 UIGesture</p>
<p> <a href="https://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views" rel="noreferrer noopener nofollow">https://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views</a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以使用此语法为 <code>UIContextualAction</code> 设置宽度和高度:</p>
<pre><code>let contextAction = UIContextualAction(style: .normal, title: "", handler: {
(param: (Bool) -> Void) in param(true)
})
contextAction.image = UIGraphicsImageRenderer(size: CGSize(160, 90)).image {
_ in UIImage(named: "someObject")!.draw(in: CGRect(40, 10, 200, 100))
}
contextAction.backgroundColor = .green
</code></pre></p>
<p style="font-size: 20px;">关于ios - 设置 UIContextualAction 大小,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/48672723/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/48672723/
</a>
</p>
页:
[1]