В то время как заглядывать и появляться в таблицеView, как мне сделать мой previewingContext.sourceRect
округленным?Force Touch TableView Cell Rounded Peek and Pop - iOS Swift
На данный момент:
Force Нажмите на TableView Cell
Установите делегат их просмотра, как например:
previewingContext.sourecRect = tableView.rectForRow (по адресу: indexPath)
Я уже пробовал установить ячейку cell.layer.cornerRadius
& cell.layer.maskToBounds = true
в cellForRowAtIndexPath
, однако предварительный просмотр soruce rect по-прежнему является идеальным прямоугольником.
Соответствующий код:
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
}
}
TableView 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
}
}
В настоящее время, когда выбран только сила прикосновения на Tableview ячейки синий прямоугольник в изображении ниже и является sourcerect , однако я хочу, чтобы оранжевый округлый прямоугольник (одной ячейки) был источником rect.
Вы также установили 'layer.masksToBounds = true'? – raidfive
Да, отредактированный вопрос, чтобы отразить это – Jerland2
без вашего текущего кода. Думаю, никто не может так помочь. отправьте соответствующие фрагменты кода – muescha