Reputation: 927
I have a UI ImageView and a few labels on the top of the screen, followed by a segmented control, with a tableView underneath.
How would you go about making the segmented control lock at the top of the screen, if the user scrolls down in the tableView?
Should everything be embedded in a scroll view, even though tableViews already have scrolling?
Upvotes: 0
Views: 776
Reputation: 4896
Set number of section in :
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
Then in :
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
switch section {
case 0:
return 0
default:
return "According to segment conrtrol height"
}
}
for first section header height will be 0 and for second section header height according to the segment control height.
Then design the UI for segment control in :
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
switch section {
case 0:
return nil
default:
"Create your UI"
}
Upvotes: 1