Adding Margin to UITableViewCell

前端 未结 3 1891
失恋的感觉
失恋的感觉 2021-02-03 15:08

I am trying to achieve a view I mocked out on sketch. I\'ve replicated it on Android cause I\'m really good on that platform. I\'m good on iOS, but the UI is kind of my weak poi

3条回答
  •  清酒与你
    2021-02-03 15:14

    Leave everything as it is. Don't try to inset your whole TableView. Create a container View inside your TableViewCell instead:

    Set the row height:

    Also in code:

    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 160.0
    }
    

    Specify the right distance to the edges:

    Now add the elements and specify the constraints as well:

    Don't forget to set the cellIdentifier:

    The result in the simulator:

    If you want to look at it under the hood: I've uploaded it as github project

提交回复
热议问题