私のアプリでは、TableViewCell
をカードのように表示するようにカスタマイズしました。私もこれらのセルにカスタムUITableViewRowActions
を実装しました。しかし、私はフローティングカードのように見えるようにレイヤーを追加したので、アクションは奇妙に見えます。カスタムサイズのtableViewCellに合わせてUITableViewRowActionのサイズを変更するにはどうすればよいですか? - Swift 3
Here's what it looks like ここに私のcellForRowAt
機能のコードがあります。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "someCell", for: indexPath) as! CustomCell
cell.delegate = self
cell.backgroundColor = .clear
cell.contentView.backgroundColor = .clear
let whiteRoundedView: UIView = UIView(frame: CGRect(x: 10, y: 8, width: self.view.frame.size.width - 20, height: cell.frame.size.height - 20))
whiteRoundedView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.9])
whiteRoundedView.layer.masksToBounds = false
whiteRoundedView.layer.cornerRadius = 2.0
whiteRoundedView.layer.shadowOffset = CGSize(width: -1, height: 1)
whiteRoundedView.layer.shadowOpacity = 0.2
cell.contentView.addSubview(whiteRoundedView)
cell.contentView.sendSubview(toBack: whiteRoundedView)
cell.updateCell()
return cell
}
そして私のUITableViewRowAction
の機能です。事前警告:私はこのSwipeCellKitリポジトリ
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
if orientation == .left {
guard isSwipeRightEnabled else { return nil }
let completeAction = SwipeAction(style: .default, title: "Complete") { (action, index) in
print("complete!")
}
completeAction.backgroundColor = .green
return [completeAction]
} else {
let deleteAction = SwipeAction(style: .destructive, title: "Delete") { (action, index) in
print("delete")
}
return [deleteAction]
}
}
を使用していますことは、細胞の型に合うようにUITableViewRowAction
のサイズを変更する方法はありますか?
この回答がお役に立てば幸いです。http://stackoverflow.com/a/12511432/1931317 – Deepak