I am trying to create custom segment control using CollectionViewCell. So i can manage text size of the segment control in different devices. But it is not working properly in all the devices.
I have taken one cell inside collection view and used sizeForItemAt delegate method to equally set the cells. There will be only 3 cells. That is shown in the image.
This is the code for sizeForItemAt
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: (collectionView.frame.width / 3), height: 50.0)
}
Here is the output that i am getting


so i am trying to find solution using which i can manage text size in all the devices and all cells can take equal spacing as well.
lbl_name.adjustsFontSizeToFitWidth = true
try this
UILabel.appearance(whenContainedInInstancesOf: [UISegmentedControl.self]).adjustsFontSizeToFitWidth = true
UILabel.appearance(whenContainedInInstancesOf: [UISegmentedControl.self]).minimumScaleFactor = 6.0