Change font size of UISegmentedControl

前端 未结 16 1846
死守一世寂寞
死守一世寂寞 2020-11-28 20:54

Can anyone please tell me how can I change the font type and size of UISegmentedControl?

16条回答
  •  没有蜡笔的小新
    2020-11-28 20:55

    Here is a Swift version of the accepted answer:

    Swift 3:

    let font = UIFont.systemFont(ofSize: 16)
    segmentedControl.setTitleTextAttributes([NSFontAttributeName: font],
                                            for: .normal)
    

    Swift 2.2:

    let font = UIFont.systemFontOfSize(16)
    segmentedControl.setTitleTextAttributes([NSFontAttributeName: font], 
        forState: UIControlState.Normal)
    

提交回复
热议问题