我想做的第一件事是在单元格中添加填充,以使带有圆圈和剪刀的图像不会碰到单元格的边界。我已经尝试过诸如cell.layoutMargins = UIEdgeInsets(top: 50,left: 50,bottom: 50,right: 50)
或cell.bounds = CGRect(x: 0,y: 0,width: 100,height: 100)
,cell.separatorInset = UIEdgeInsets(top: 100,left: 100,bottom: 100,right: 100)
之类的东西,但没有任何改变。
我想要的第二件事是在单元格之间添加一个间距,我尝试了所有发现的解决方案,但似乎不起作用
代码(我尝试过的一些解决方案都是一起编写的,但是我也一次尝试过它们)
func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "difficultyCell",for: indexPath)
cell.textLabel?.text = myDict[indexPath.row].key
cell.textLabel?.font = .boldSystemFont(ofSize: 20)
let imageCell = UIImage(named: "scissors.png")
cell.imageView?.image = imageCell
cell.backgroundColor = Esercizio.hexStringToUIColor(hex: "#4cf584").withAlphaComponent(0.85)
cell.layer.borderColor = UIColor.orange.cgColor
cell.layer.borderWidth = 1
cell.layer.cornerRadius = 8
cell.layoutMargins = UIEdgeInsets(top: 50,right: 50)
cell.bounds = CGRect(x: 0,height: 100)
cell.separatorInset = UIEdgeInsets(top: 100,right: 100)
return cell
}