gpt4 book ai didi

ios - 设置 UIContextualAction 大小

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:04:44 26 4
gpt4 key购买 nike

我想知道是否可以设置 UIContextualAction 大小(宽度和高度)。

我没有在 UIContextualAction 中找到任何允许我这样做的成员,所以我想知道是否有解决方法可以做到这一点?

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

result

更新

我找到这篇文章,背后的想法是使用自定义按钮和使用 UIGesture

https://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views

最佳答案

您可以使用此语法为 UIContextualAction 设置宽度和高度:

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

关于ios - 设置 UIContextualAction 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48672723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com