Dragging and dropping a segmented controller from object library is so easy but that one is not always the requirement. I need to implement custom underline type segmented controller but I found it so difficult. The codes I found online are just going above my head. Can someone suggest easy implementation of underline type custom segmented controller?
Layman and the easiest approach could be that, you place two labels on your view. and under each label you place one progress bar. Make progress bars hidden by default. Create @IBOutlets for these progress bars and labels. Assign constraints carefully. Now drag a segmented controller from object library and place over these. Make the tint as clear/transparent. Create outlets for this segmented controller now.
Now, upon selection of the segmented controller what you can do is that you can make the label underneath that segment bold and at the same time you can unhide the hidden progress bar for the segment selected. Unbold the unselected label with original font replacement.
Hope you understand with example of providing and seeking segments.
Let me write the code for it, comment if you face any issue:
@IBAction func selection(_ sender: Any) {//outlet to UISegmentedControler
let sel = segmt.selectedSegmentIndex
if sel == 0 {
Providing.font = selectedFont //selected font is bold font
Seeking.font = fonts //original font for seeking
p.isHidden = false
s.isHidden = true
}
else if sel == 1 {
Seeking.font = selectedFont
Providing.font = fontp //original font for providing
s.isHidden = false
p.isHidden = true
}
else{
//code..
}
}