내 앱에서 내 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