Custom UISegmentedControl

后端 未结 10 2083
我寻月下人不归
我寻月下人不归 2020-12-04 10:23

How do I make a custom UISegmentedControl?

I have 2 images, 1 that should be displayed when the segment is active and the other if the segment is inacti

10条回答
  •  情深已故
    2020-12-04 10:52

    Swift 3.0 Version of Jon's answer.

    var transparentImage = UIGraphicsGetImageFromCurrentImageContext() as? UIImage
    UIGraphicsEndImageContext()
    segControl.setBackgroundImage(transparentImage, for: .normal, barMetrics: .default)
    segControl.setDividerImage(transparentImage, forLeftSegmentState: .normal, rightSegmentState: .normal, barMetrics: .default)
    

提交回复
热议问题