2017-01-27 12 views
0

tableViewでピークとポップが発生している間に、previewingContext.sourceRectを丸くするにはどうすればよいですか?現時点でForce Touch TableViewセルが丸みを帯びたピックとポップ - iOS Swift

:テーブルビューのセルに

  1. フォースタッチのようなプレビューデリゲートを設定し

  2. previewingContext.sourecRect = tableView.rectForRow(時:indexPath)

私はすでにセルのを設定しようとしました& cell.layer.maskToBounds = truecellForRowAtIndexPathであるが、プレビューソートレットは依然として完全な長方形である。

関連コード:テーブルビューのセルに以下の画像に青いボックスに触れるだけの力が選択さsourcerectである

UIVIewControllerPreviewingDelegate

func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { 
    if tableView.isEditing == false { 
     guard let indexPath = tableView.indexPathForRow(at: location) else { 
      print("Nil Cell Found: \(location)") 
      return nil } 
     guard let detailVC = storyboard?.instantiateViewController(withIdentifier: "view") as? ViewController else { return nil } 


     previewingContext.sourceRect = tableView.rectForRow(at: indexPath) 


     return detailVC 

    } else { 
     return nil 

    } 
} 

テーブルビューCellForRowAtIndexPath現在

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

      guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? CustomCell else { fatalError("No cell with identifier: cell") } 

      cell.titleLabel.text = "temp" 

//   cell.inputView?.layer.cornerRadius = 16.0 
//   cell.inputView?.layer.masksToBounds = true 

//   cell.contentView.layer.cornerRadius = 16.0 
//   cell.contentView.layer.masksToBounds = true 

      cell.layer.cornerRadius = 16.0 
      cell.layer.borderWidth = 2 
      cell.layer.borderColor = UIColor.orange.cgColor 
      cell.layer.masksToBounds = true 

      return cell 

     } 

    } 

私はオレンジ色の丸い矩形(1つのセルの)をソースの矩形にしたい。

enter image description here

+0

'layer.masksToBounds = true'も設定しましたか? – raidfive

+0

はい、あなたの現在のコードなしで – Jerland2

+0

を反映する編集された質問私は誰もそれほど多くを助けることができると思います。関連するコードスニペットを投稿してください – muescha

答えて

0

あなたのPeekが通常ViewControllerのように円Popになりたいですか? sourceRectはプレビュー(この場合はセル)のソースであり、実際のプレビューではないためです。

通常、あなたがかいま見が円になりたい場合は、これを試してみてください、そしてポップ:あなたpreviewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController?オン

をあなたは

detailVC.view.layer.cornerRadius = detailVC.view.bounds.width/2 
detailVC.view.layer.masksToBounds = true 

そして、あなたのpreviewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController)上を返す前にこれを追加するには

を表示する前にこれを追加
detailVC.view.layer.cornerRadius = 0 
show(detailVC, sender: self) 
+0

私は、プレビューコンテキストソースrectを丸い四角形のセルとして探しています。私はピークとポップの両方をバニラしておきたい。しかし、私がテーブルビューのセルに触れ始めると、セル全体が(矩形として)使用されます。私は達成しようとしているものが表示された画像で投稿を更新します – Jerland2

関連する問題