I need to add some extra space after the last element in the table view cell.
In android reccycler view, the same thing can be achieved by
android:paddingBottom="8dp"
android:clipToPadding="false"
The way I achieve adding spacing between cells is to make numberOfSections = "Your array count" and make each section contains only one row. And then define headerView and its height. This works great.
Overview. Table views in iOS display rows of vertically scrolling content in a single column. Each row in the table contains one piece of your app's content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settings ...
UITableViews are one of the most commonly used views in iOS programming. They are used to display grouped lists of cells. Here are some examples of UITableViews : UITableViews can be highly performant, displaying thousands of rows of data.
You need to add insets to your tableView . Try the following code
let insets = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0)
tableView.contentInset = insets
Add datasource and delegate for your tableview and utilize following delegate methods:
- heightForFooterInSection
& viewForFooterInSection
// set view for footer
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let footerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 40)) // assuming 40 height for footer.
footerView.backgroundColor = <Some Color>
return footerView
}
// set height for footer
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 40
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With