Open SathiyakumarIOS opened 5 years ago
Try this workaround, this worked for me. (note: change the font size in didload)
override func viewDidAppear(_ animated: Bool) {
let lastSegmantNo = segmentedControl.numberOfSegments-1
let lastTitle = segmentedControl.titleForSegment(at: lastSegmantNo) ?? ""
if(segmentedControl.selectedSegmentIndex == lastSegmantNo) {
segmentedControl.removeSegment(at: lastSegmantNo)
segmentedControl.insertSegment(withTitle:lastTitle , at: lastSegmantNo)
segmentedControl.selectedSegmentIndex = lastSegmantNo
} else {
segmentedControl.removeSegment(at: lastSegmantNo)
segmentedControl.insertSegment(withTitle:lastTitle , at: lastSegmantNo)
}
}
When I try to set font size manually as like you have mentioned but no luck. Please come up with solution ASAP.
My code,
let largerRedTextAttributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20), NSAttributedStringKey.foregroundColor: UIColor.white] let largerRedTextHighlightAttributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20), NSAttributedStringKey.foregroundColor: UIColor.white] let largerRedTextSelectAttributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 20), NSAttributedStringKey.foregroundColor: UIColor.white]
segmentedControl.setTitleTextAttributes(largerRedTextAttributes, for: .normal) segmentedControl.setTitleTextAttributes(largerRedTextHighlightAttributes, for: .highlighted) segmentedControl.setTitleTextAttributes(largerRedTextSelectAttributes, for: .selected)