How to remove border from segmented control

后端 未结 9 2214
刺人心
刺人心 2020-12-03 05:04

How do I remove the outside border of a segmented control? I\'ve set the divider image to what I wanted but now to follow the mock of my app I need to have a segmented cont

9条回答
  •  不思量自难忘°
    2020-12-03 05:39

    If you need segment control with texts Only, use,

    segmentControl.backgroundColor = .clear
    segmentControl.tintColor = .clear
    
    let attributes: [NSAttributedString.Key : Any] = [.font : UIFont(family: .medium, ofSize: 13)!, .foregroundColor : UIColor.white]
    segmentControl.setTitleTextAttributes(attributes, for: .normal)
    
    let selectedAttrib: [NSAttributedString.Key : Any] = [.font : UIFont(family: .medium, ofSize: 13)!, .foregroundColor : UIColor.red]
    segmentControl.setTitleTextAttributes(hightLightedStateAttrib, for: .selected)
    

    NB: I googled it for a long time, thats why i'm posted here.

    Source: CodeMentor

提交回复
热议问题