Reputation: 217
so I want to make something similar like this from Health App, where the 'Favorites' title is separated with the cell.
Here's what my UI now :
So I want to make the background curves on the first cell, instead of the header title. Is that possible?
I've been looking around and I didn't get any solution. Here's the code I have created so far :
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let label = UILabel()
label.text = "Smaller Title"
label.font = .boldSystemFont(ofSize: 22)
label.textColor = UIColor.black
label.backgroundColor = UIColor.clear
label.textAlignment = .left
label.translatesAutoresizingMaskIntoConstraints = false
let headerView = UIView()
headerView.backgroundColor = UIColor.clear
headerView.addSubview(label)
label.leftAnchor.constraint(equalTo: headerView.leftAnchor).isActive = true
return headerView
}
Upvotes: 0
Views: 554
Reputation: 16381
Here the UITableView
has a .white
backgroundColor
. Try setting the backgroundColor
of UITableView
as .clear
and customize the UITableViewCells
to have the .white
backgroundColor
.
tableView.backgroundColor = .clear
Upvotes: 1