2017-02-23 7 views
0

내 앱에서 내 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 크기를 조정할 수있는 방법이 있습니까를 사용하고?

+0

희망 답변이 도움이 될 수 있습니다. http://stackoverflow.com/a/12511432/1931317 – Deepak

답변

0

프레임 워크를 약간 변경하지 않으면 현재 가능하지 않습니다.

SwipeTableViewCellDelegate에 몇 가지 방법을 추가하여 표시하기 바로 전에 각 UIButton을 노출시킬 계획이 있으며 스 와이프가 계속 발생합니다. 나는 그것이 당신에게 당신의 배치를 성취 할 수있는 충분한 유연성을 줄 것이라고 상상한다.

그 동안 자신의 포크로하기가 너무 어렵지 않아야합니다. 특히 configureActionView 방법의 내부에서 SwipeTableViewCell을 확인하십시오. 스 와이프 UIButton 하위 클래스가 포함 된 buttons 속성이있는 SwipeActionsView을 만듭니다. 그것들을 당신의 앱에 드러내기만하면됩니다.