ScrollableSegmentedControl icon indicating copy to clipboard operation
ScrollableSegmentedControl copied to clipboard

Can't able to change font size

Open SathiyakumarIOS opened this issue 6 years ago • 1 comments

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)

SathiyakumarIOS avatar Jul 26 '19 05:07 SathiyakumarIOS

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)
        }
    }

Mithsen avatar Jul 02 '20 05:07 Mithsen