Rounded edges in tables + Swift 3 shadow

0

How can I make the edges of my table look rounded and not straight. as in each line.

And add a shadow to the table

The edges of the table are round

    
asked by Eduardo Díaz 17.11.2016 в 15:55
source

2 answers

1

put your table in a UIView container (the table with constraints 0 to the 4 edges of this view)

@IBOutlet weak var containerView: UIView!
@IBOutlet weak var tableview: UITableView!

then you can do, for example in ViewDidLoad :

override func viewDidLoad() {
    super.viewDidLoad()
    // bordes redondeados
    self.tableview.layer.cornerRadius = 5.0
    self.tableview.layer.masksToBounds = true

    // sombras
    self.containerView.layer.masksToBounds = false
    self.containerView.layer.shadowColor = UIColor.black.cgColor
    self.containerView.layer.shadowOffset = CGSize(width: 0, height: 5)
    self.containerView.layer.shadowOpacity = 0.5
    self.containerView.backgroundColor = UIColor.clear
}
    
answered by 17.11.2016 в 18:03
0

To make the rounded edges you can make:

self.tableView.layer.cornerRadius = 5 //Este valor es el radio que van a tener los bordes
    
answered by 17.11.2016 в 16:13