ios - Delete button not showing on UITableViewCell with rounded corners -
in tableview, have logic in tableview(tableview: uitableview, willdisplaycell cell: uitableviewcell, forrowatindexpath indexpath: nsindexpath)
determine if cell has rounded corners on top, bottom, or no rounded corners @ all.
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 } } }
this works, after have implemented editing tableview, strange things happen delete button.
with rounded corners code:
when remove rounded corners:
this confuses me because i'm not sure i'm doing wrong. can help?
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.contentview.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.contentview.layer.mask = masklayer } } }
use cell.contentview.layer.mask = masklayer
deallooks.com
ReplyDelete