How to give space between two cells in tableview?

前端 未结 26 1523
谎友^
谎友^ 2020-11-29 00:11

I want a space between two cell in table view,

I want cell like this,

\"enter<

26条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 00:58

    I suggest to create a custom UITableViewCell base class and use this class like below,

    1. Create custom UITableViewCell class
    2. Create a UIView in new class, this will act as the 'baseContentView' and it will be immediate child of 'UITableViewCell.contentView'
    3. Adjust the top 'padding' on 'baseContentView' (this will be the separator/gap) from parent view (UITableViewCell.contentView)
    4. Inherit all your custom classes from this class rather than UITableViewCell
    5. Add all the content/subviews to 'baseContentView' rather than 'self.contentView'

    You can play with the 'padding' as per your need.

提交回复
热议问题