func numberOfSections(in tableView: UITableView) -> Int
{
return 2
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return 3
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
{
let lblSectionTitle = UILabel()
lblSectionTitle.text = "Titulo Seccion"
lblSectionTitle.textAlignment = .center
lblSectionTitle.backgroundColor = .groupTableViewBackground
lblSectionTitle.textColor = UIColor.black
lblSectionTitle.font = UIFont(name: "HelveticaNeue-Light", size: 16)
return lblSectionTitle
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
{
return 35.0
}
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
{
return true
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
{
let delete = UITableViewRowAction(style: .destructive, title: "Remove", handler: { (action, indexPath) -> () in
tableView.setEditing(false, animated: true)
}
return [delete]
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = UITableViewCell(style: .default, reuseIdentifier:"Cell")
//Color for selected cell
let selectedColor = UIView()
selectedColor.layer.backgroundColor = UIColor.white.cgColor
cell.selectedBackgroundView = selectedColor
cell.textLabel?.text = "hola"
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
tableView.deselectRow(at: indexPath, animated: true)
let cell = tableView.cellForRowAtIndexPath(indexPath) as UITableViewCell!
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
{
// Remove seperator inset
if cell.responds(to: #selector(setter: UITableViewCell.separatorInset))
{
cell.separatorInset = UIEdgeInsets.zero
}
// Prevent the cell from inheriting the Table View's margin settings
if cell.responds(to: #selector(setter: UIView.preservesSuperviewLayoutMargins))
{
cell.preservesSuperviewLayoutMargins = false
}
// Explictly set your cell's layout margins
if cell.responds(to: #selector(setter: UIView.layoutMargins))
{
cell.layoutMargins = UIEdgeInsets.zero
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return CGFloat.leastNormalMagnitude
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat
{
return CGFloat.leastNormalMagnitude
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
{
return UIView()
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.