私のテーブルビューでは、tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath)
にロジックがあり、セルの上端、下端、または丸みのない角に丸みがあるかどうかを判断できます。丸い角を持つUITableViewCellに削除ボタンが表示されない
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {
// round top 2 corners
let maskLayer = CAShapeLayer()
maskLayer.path = UIBezierPath(roundedRect: cell.bounds, byRoundingCorners: [UIRectCorner .TopLeft, UIRectCorner .TopRight], cornerRadii: CGSizeMake(4, 4)).CGPath
cell.layer.mask = maskLayer
}
if indexPath.section != 1 {
if indexPath.row == self.tableView.numberOfRowsInSection(indexPath.section) - 1 {
let maskLayer = CAShapeLayer()
maskLayer.path = UIBezierPath(roundedRect: cell.bounds, byRoundingCorners: [UIRectCorner .BottomLeft, UIRectCorner .BottomRight], cornerRadii: CGSizeMake(4, 4)).CGPath
cell.layer.mask = maskLayer
}
}
}
これは動作しますが、私はテーブルビューに編集を実装した後に、奇妙なことは、削除ボタンに起こります。私は角の丸い削除すると
:
を、私は私がやっているかわからないんだけどこれは本当に私を混乱角の丸いコード付き
違う。誰も助けることができますか?
あなたは 'cell.layer.maskToBounds = true'を追加することを試みたことがありますか? –
おそらく、これをセルのビューに直接行うべきではありません。代わりに、レイヤーマスクをセルの 'contentView'に適用し、それが機能するかどうか確認してください。 – Bringo